Re: [R] sum(hist$density) == 2 ?!
Your clue is... density! Probability density is not the same as probability... you have to multiply it by something before you can sum it. Try typing h by itself and review your options. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Sam Steingold s...@gnu.org wrote: x - rnorm(1000) h - hist(x,plot=FALSE) sum(h$density) [1] 2 - shouldn't it be 1?! h - hist(x,plot=FALSE, breaks=(-4:4)) sum(h$density) [1] 1 - now it's 1. why?! -- Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000 http://www.childpsy.net/ http://www.memritv.org http://openvotingconsortium.org http://thereligionofpeace.com http://mideasttruth.com http://palestinefacts.org ((lambda (x) `(,x ',x)) '(lambda (x) `(,x ',x))) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Merging fully overlapping groups
Hi, I have data on individuals (B) who participated in events (A). If ALL participants in an event are a subset of the participants in another event I would like to remove the smaller event and if the participants in one event are exactly similar to the participants in another event I would like to remove one of the events (I don't care which one). The following example does that however it is extremely slow (and the true dataset is very large). What would be a more efficient way to solve the problem? I really appreciate your help. Thanks! DF - data.frame(read.table(textConnection( A B 1209569832 1209551750 120956734 1877451750 1877451733 187746734 1877469833 1926851750 192686734 1926851733 1926865251 5169 54441 5169 15480 5169 3228 5966 51733 5966 65251 5966 68197 5966 6734 5966 51750 5966 69833 7189 135523 7189 65251 7189 51733 7189 69833 7189 135522 7189 68197 7189 6734 7797 51750 7797 6734 7797 69833 7866 6734 7866 69833 7866 51733 8596 51733 8596 51750 8596 65251 8677 6734 8677 51750 8677 51733 8936 68197 8936 6734 8936 65251 8936 51733 9204 51750 9204 69833 9204 6734 9204 51733),head=TRUE,stringsAsFactors=FALSE)) data - unique(DF$A) for (m in 1:length(data)) { for (m in 1:length(data)) { tdata - data[-m] q - 0 for (n in 1:length(tdata)) { if (length(which(DF[DF$A == data[m], 2] %in% DF[DF$A == tdata[n], 2] == TRUE)) == length(DF[DF$A == data[m], 2])) { q - q + 1 } } if (q 0) { data - data[-m] m - m - 1 } } } DF - DF[DF$A %in% data,] -- View this message in context: http://r.789695.n4.nabble.com/Merging-fully-overlapping-groups-tp4470999p4470999.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re : ROC Analysis
Hi Camille, Do you need something like that? ### library(ROCR) data(ROCR.simple) pred - prediction(ROCR.simple$predictions, ROCR.simple$labels) tpf - unlist(performance(pred,tpr)@y.values) tnf - unlist(performance(pred,tnr)@y.values) x - rev(unlist(pred@cutoffs)) plot(x, tpf+tnf, t='l', xlab='Value', ylab='TPF+TNF') ### Regards, Pascal - Mail original - De : Camille Leclerc camille.lecl...@ymail.com À : r-help@r-project.org Cc : Envoyé le : Mardi 13 mars 2012 23h30 Objet : [R] ROC Analysis Hi everybody, I have a data set with a value and a status (positive or negative case) and I want make a ROC Analysis. So, with ROCR Package, I have got the ROC curve (True Positive Fraction [tpf] according 1-True Negative Fraction [1-tnf]). http://r.789695.n4.nabble.com/file/n4469203/01.png But, now I want a new graphic which show the sum of true positive fraction and true negative fraction according each value on my data set (tpf + tnf according the values). http://r.789695.n4.nabble.com/file/n4469203/02.png If you have an idea ! Thank you very much for all help, Camille Leclerc -- Camille Leclerc, Master student Lab ESE, UMR CNRS 8079 Univ Paris-Sud Bat 362 F-91405 Orsay Cedex FRANCE -- View this message in context: http://r.789695.n4.nabble.com/ROC-Analysis-tp4469203p4469203.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with plot Grouped Bar Plot by using R
Thanks a lot, Jim. I get my desired output by using your R script at the end Yesterday was my mistake Apart from that, do you have any idea to plot a line graph/chart? My Input file is shown as below: Range Data1 Data2 1 38 37 2 38 37 3 38 37 4 37 37 5 37 37 6 37 37 7 37 37 8 37 37 9 37 37 10 37 37 11 37 37 12 37 37 13 37 37 14 37 37 15 37 37 16 37 37 17 37 37 18 37 37 19 37 37 20 37 37 21 37 36 22 37 36 23 37 36 24 37 36 25 37 36 26 37 36 27 36 36 28 36 36 29 36 36 30 36 36 31 36 36 32 36 36 33 36 36 34 36 36 35 36 36 36 36 36 37 36 36 38 36 36 39 36 36 40 36 36 Thanks for your further notice and advice :) -- View this message in context: http://r.789695.n4.nabble.com/Help-with-plot-Grouped-Bar-Plot-by-using-R-tp4448762p4471020.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem installing RMySQL package!
I am facing issues while installing RMySQL package on windows(32 bit) installation of R-Project. I am getting the following warning messages. Warning messages: 1: running command 'C:/PROGRA~1/R/R-213~1.2/bin/i386/R CMD INSTALL -l C:/Program Files/R/R-2.13.2/library D:\DOCUME~1\nagga002\LOCALS~1\Temp\RtmpLZndlE/downloaded_packages/RMySQL_0.9-3.tar.gz' had status 1 2: In install.packages(RMySQL, type = source) : installation of package 'RMySQL' had non-zero exit status It seems many people faced the issue and some got it resolved manipulating with some jars. I got one solution from - http://stackoverflow.com/questions/4785933/adding-rmysql-package-to-r-fails/5236954#5236954 The basic process is described herehttp://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL, but there are several hints, So I will describe the whole solution(please change the R version and paths if needed): 1. Install latest RTools from herehttp://www.murdoch-sutherland.com/Rtools/ 2. install MySQL or header and library files of mysql 3. create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line likeMYSQL_HOME=C:/mysql (path to your mysql files) 4. copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies. 5. copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32 directory. 6. run install.packages('RMySQL',type='source') and wait while compilation will end. This worked for me on Windows 7 64 bit, so there should be no problems with 32 bit versions II tried the above steps, but I am still facing problems. Is RTools something different from RProject. I did not find anything by the name RTools at the given link? Regards, Neeraj Aggarwal [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Questing on fitting Baseline category Logit model
Dear all, I am facing some problem with how to fit a Baseline category Logit model with R. Basically I am considering famous Alligator data as discussed by Agresti. This data can also be found here: https://onlinecourses.science.psu.edu/stat504/node/174 (there is also an accompanying R file, however the underlying R code could not load the data properly!!!) Below are the stuffs what I have done so far: My_Data - structure(list(Number = c(7L, 4L, 1L, 0L, 0L, 0L, 0L, 1L, 5L, 2L, 16L, 3L, 3L, 0L, 2L, 1L, 2L, 2L, 3L, 3L, 2L, 13L, 2L, 7L, 0L, 6L, 0L, 0L, 1L, 0L, 3L, 0L, 9L, 1L, 1L, 0L, 0L, 1L, 2L, 0L, 3L, 8L, 7L, 6L, 1L, 6L, 0L, 3L, 1L, 5L, 2L, 0L, 4L, 1L, 1L, 0L, 1L, 0L, 4L, 0L, 13L, 9L, 10L, 0L, 0L, 0L, 2L, 1L, 2L, 2L, 3L, 8L, 9L, 1L, 1L, 0L, 0L, 0L, 1L, 1L), Food = structure(c(2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L), .Label = c(Bird, Fish, Invertebrate, Other, Reptile), class = factor), Size = structure(c(2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L), .Label = c(Large, Small), class = factor), Sex = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(Female, Male), class = factor), Lake = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(George, Hancock, Oklawaha, Trafford), class = factor)), .Names = c(Number, Food, Size, Sex, Lake), row.names = c(NA, 80L), class = data.frame) library(VGAM) vglm(Food~Size+Sex+Lake, data = My_Data, fam=multinomial, weights = Number) However I am getting following error: Error in if (max(abs(ycounts - round(ycounts))) smallno) warning(converting 'ycounts' to integer in @loglikelihood) : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 2: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 3: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 4: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 5: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 6: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 Can somebody points me why I am getting this error? Thanks for you help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re : sum(hist$density) == 2 ?!
Hi Sam, ?hist gives: density values f^(x[i]), as estimated density values. If all(diff(breaks) == 1), they are the relative frequencies counts/n and in general satisfy sum[i; f^(x[i]) (b[i+1]-b[i])] = 1, where b[i] = breaks[i]. 1st case, density != frequency because all(diff(breaks) == 1) is FALSE (diff = 0.5); sum(h$density*diff) = 1 2nd case, density == frequency because all(diff(breaks) == 1) is TRUE (diff = 1); sum(h$density*diff) = 1 Regards, Pascal -- Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000 http://www.childpsy.net/ http://www.memritv.org http://openvotingconsortium.org http://thereligionofpeace.com http://mideasttruth.com http://palestinefacts.org ((lambda (x) `(,x ',x)) '(lambda (x) `(,x ',x))) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cannot load shared object /usr/lib/R/library/grDevices/libs//cairo.so
Hi, I am trying to test out the scripts here as a proof of concept http://www.r-bloggers.com/integrating-php-and-r/ However, I am not able to reproduce the output graph in the browser. Rscripts is working fine as I run the command Rscript /home/username/R/testscript.R 1000 for example, and a png graph is output as expected, and I can output it to any folder where I have permission by changing testscript.R. However I am not able to get the output on the browser.I checked the web root on my test server (xampp for Linux) and found that a pdf file is created instead (Rplots.pdf) I checked xampp's error log and found these, I think it is the reason why a png graph is not created by using php's exec() command. unable to load shared object '/usr/lib/R/library/grDevices/libs//cairo.so': /usr/lib/i386-linux-gnu/libfontconfig.so.1: undefined symbol: FT_Select_Size I notice that there are two forward slashes in ..grDevices/libs//cairo.so whereas it should be just ..grDevices/libs/cairo.so I am wondering if this is a problem. Also it seemed to be working before. It somehow stops today. I am using Ubuntu 11.04 and R 2.14.2 (from this ppa https://launchpad.net/~marutter/+archive/rrutter) and my test server is xampp for Linux, I would appreciate any help. Thank you. -- View this message in context: http://r.789695.n4.nabble.com/cannot-load-shared-object-usr-lib-R-library-grDevices-libs-cairo-so-tp4471075p4471075.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to find best model of time series?giving error
yes but giving error t-read.table(file.choose()) t-ts(t) plot(t) Hit Return to see next plot: ht-HoltWinters(t) Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) : time series has no or less than 2 periods what should i do? -- View this message in context: http://r.789695.n4.nabble.com/how-to-find-best-model-of-time-series-tp4469296p4471097.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Creating 250 submatrices from a large single matrix with 2500 variables using loops
Dear all, I have a large matrix with about 2500 variables, and 100 rows. I would like to calculate the means of the every 10 variables starting from 1:2500 and saving the results as a vector or matrix. How can I do that? Alternatively, How can I create 250 subset matrices in the order of variables 1:2500 in groups of 10 from the single matrix which had initially 2500 variables ? I guess I have to use a loop, but I can't figure out how. Any help will be appreciated, Regards, Lazarus [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Apply a loop containing a function on a list
Hi all, I want to do this: B.list$aa= (a loop containing My.fun acting on the reults of second function on a A.list$aa)) or, overally B.list$aa = function (A.list$aa) B.list and A.list has many sublists aa, ab and Is there a way I can apply the function and loop on all sublists of A.list and get B.list? Thanks in advance. -- View this message in context: http://r.789695.n4.nabble.com/Apply-a-loop-containing-a-function-on-a-list-tp4471188p4471188.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshaping a dataset for a network
Thank you fro the reply. I managed to arrive till here, then I would like to have it in matrix where the $1 $2...$5 are the first column. Il 3/13/2012 8:15 PM, William Dunlap ha scritto: Is the following what you want? a- c(1,2,3,4,4,4,5,5) b- c(11,7,4,9,8,3,12,4) split(b, a) $1 [1] 11 $2 [1] 7 $3 [1] 4 $4 [1] 9 8 3 $5 [1] 12 4 Here I did c - split(b, a) d - do.call(rbind,c) and I get [,1] [,2] [,3] 1 11 11 11 2777 3444 4983 5 124 12 Instead of what I would like: [,1] [,2] [,3] 1 11 27 34 4983 5 124 A solution could be rbind.fill , which does not seem to work with list. thanks Marco Guerzoni, Department of Economics University of Turin Note that your df-cbind(a,b) produces a matrix, not the data.frame that your df suggests you want. Use df-data.frame(a,b) to make a data.frame. Then you could do with(df, split(a,b)) to operate on the a and b in the data.frame df. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Marco Guerzoni Sent: Tuesday, March 13, 2012 10:51 AM To: r-help@r-project.org Subject: [R] reshaping a dataset for a network dear all, apologizes for bothering with a probably stupid question but I really don' t know how to proceed. I have a dataset which look like df a- c(1,2,3,4,4,4,5,5) b- c(11,7,4,9,8,3,12,4) df-cbind(a,b) I would like to have one which looks like this: a 1 11 2 7 3 4 4 9 8 3 5 12 4 a are vertex of a network, b the edges. In the data the lenght of a is about 5 I read several posts about reshape, reshape2, split, ldply but I couldn't manage to do it. The problem seems to be that the is not a real panel. Any help would be really appreciated, my best regards Marco __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating 250 submatrices from a large single matrix with 2500 variables using loops
Hi Lazarus, Checkout arrays (?array). You can cast your matrix to an array of submatrices, and calculate the means per block using apply. Cheers, Tsjerk On Mar 14, 2012 9:25 AM, Lazarus Mramba lmra...@gmail.com wrote: Dear all, I have a large matrix with about 2500 variables, and 100 rows. I would like to calculate the means of the every 10 variables starting from 1:2500 and saving the results as a vector or matrix. How can I do that? Alternatively, How can I create 250 subset matrices in the order of variables 1:2500 in groups of 10 from the single matrix which had initially 2500 variables ? I guess I have to use a loop, but I can't figure out how. Any help will be appreciated, Regards, Lazarus [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Partial Canonical Correlation Analysis Help
Hello, I am trying to perform partial Canonical Correlation (CCA) in R. I have calculated the CCA between two vectors X and Y and now I want to control for Z. I know I have to modify the cc and rcc functions to include Z but what I am doing does not seem to be working... Below I have the original code and my modified code Original cc: function (X, Y) { Xnames = dimnames(X)[[2]] Ynames = dimnames(Y)[[2]] ind.names = dimnames(X)[[1]] res = rcc(X, Y, 0, 0) return(res) } I changed this to: function (X, Y, Z) { Xnames = dimnames(X)[[2]] Ynames = dimnames(Y)[[2]] Znames = dimnames(Z) [[2]] ind.names = dimnames(X)[[1]] res = rcc2(X, Y, Z, 0, 0, 0) return(res) } and then for rcc Original rcc: function (X, Y, lambda1, lambda2) { Xnames - dimnames(X)[[2]] Ynames - dimnames(Y)[[2]] ind.names - dimnames(X)[[1]] Cxx - var(X, na.rm = TRUE, use = pairwise) + diag(lambda1, ncol(X)) Cyy - var(Y, na.rm = TRUE, use = pairwise) + diag(lambda2, ncol(Y)) Cxy - cov(X, Y, use = pairwise) res - geigen(Cxy, Cxx, Cyy) names(res) - c(cor, xcoef, ycoef) scores - comput(X, Y, res) return(list(cor = res$cor, names = list(Xnames = Xnames, Ynames = Ynames, ind.names = ind.names), xcoef = res$xcoef, ycoef = res$ycoef, scores = scores)) } I know I have to calculate Czz Czx and Czy but do I have to calculate Cxy.z (partial covariance)? and I am not sure what to add in the res- geigen etc when I add Czz and/or Czx Czy I get an error - I have also left scores and return ans original since I am not sure what to include modified rcc2 function (X, Y, Z, lambda1, lambda2, lambda3) { Xnames - dimnames(X)[[2]] Ynames - dimnames(Y)[[2]] Znames - dimnames(Z)[[2]] ind.names - dimnames(X)[[1]] Cxx - var(X, na.rm = TRUE, use = pairwise) + diag(lambda1, ncol(X)) Cyy - var(Y, na.rm = TRUE, use = pairwise) + diag(lambda2, ncol(Y)) Czz - var(Z, na.rm = TRUE, use = pairwise) + diag(lambda3, ncol(Z)) Cxy - cov(X, Y, use = pairwise) Czx - cov(X, Z, use = pairwise) Czy - cov(Y, Z, use = pairwise) # Cxy.z? res - geigen(Cxy, Cxx, Cyy, Czz, Czx, Czy) # doesnt work names(res) - c(cor, xcoef, ycoef, zcoef) scores - comput(X, Y, Z, res) return(list(cor = res$cor, names = list(Xnames = Xnames, Ynames = Ynames, Znames=Znames, ind.names = ind.names), xcoef = res$xcoef, ycoef = res$ycoef, zcoef = res$zcoef, scores = scores)) } Any help would be really appreciated..I am completely new to this and lost. many thanks Joe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating 250 submatrices from a large single matrix with 2500 variables using loops
On Wed, Mar 14, 2012 at 03:22:39AM -0400, Lazarus Mramba wrote: Dear all, I have a large matrix with about 2500 variables, and 100 rows. I would like to calculate the means of the every 10 variables starting from 1:2500 and saving the results as a vector or matrix. How can I do that? Alternatively, How can I create 250 subset matrices in the order of variables 1:2500 in groups of 10 from the single matrix which had initially 2500 variables ? I guess I have to use a loop, but I can't figure out how. Hi. Try the following. I will use smaller parameters for simplicity. # a matrix 3 times 20 a - matrix(1:60, nrow=3, ncol=20) a [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [1,]147 10 13 16 19 22 2528313437 40 [2,]258 11 14 17 20 23 2629323538 41 [3,]369 12 15 18 21 24 2730333639 42 [,15] [,16] [,17] [,18] [,19] [,20] [1,]434649525558 [2,]444750535659 [3,]454851545760 #combine each 5 consecutive columns to a single column dim(a) - c(15, 4) a [,1] [,2] [,3] [,4] [1,]1 16 31 46 [2,]2 17 32 47 [3,]3 18 33 48 [4,]4 19 34 49 [5,]5 20 35 50 [6,]6 21 36 51 [7,]7 22 37 52 [8,]8 23 38 53 [9,]9 24 39 54 [10,] 10 25 40 55 [11,] 11 26 41 56 [12,] 12 27 42 57 [13,] 13 28 43 58 [14,] 14 29 44 59 [15,] 15 30 45 60 # compute column means colMeans(a) [1] 8 23 38 53 Hope this helps. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating 250 submatrices from a large single matrix with 2500 variables using loops
Hi Lazarus, Sorry for my brevity before. I sent it from a phone. # Generate dummy data matrix x - matrix(1:100,nrow=5) # Rearrange into array; ten groups of two columns y - array(x,c(5,2,10)) # Average columns for each submatrix apply(y,c(1,3),mean) # Average per submatrix apply(y,3,mean) Hope it helps, Tsjerk On Wed, Mar 14, 2012 at 10:01 AM, Petr Savicky savi...@cs.cas.cz wrote: On Wed, Mar 14, 2012 at 03:22:39AM -0400, Lazarus Mramba wrote: Dear all, I have a large matrix with about 2500 variables, and 100 rows. I would like to calculate the means of the every 10 variables starting from 1:2500 and saving the results as a vector or matrix. How can I do that? Alternatively, How can I create 250 subset matrices in the order of variables 1:2500 in groups of 10 from the single matrix which had initially 2500 variables ? I guess I have to use a loop, but I can't figure out how. Hi. Try the following. I will use smaller parameters for simplicity. # a matrix 3 times 20 a - matrix(1:60, nrow=3, ncol=20) a [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [1,] 1 4 7 10 13 16 19 22 25 28 31 34 37 40 [2,] 2 5 8 11 14 17 20 23 26 29 32 35 38 41 [3,] 3 6 9 12 15 18 21 24 27 30 33 36 39 42 [,15] [,16] [,17] [,18] [,19] [,20] [1,] 43 46 49 52 55 58 [2,] 44 47 50 53 56 59 [3,] 45 48 51 54 57 60 #combine each 5 consecutive columns to a single column dim(a) - c(15, 4) a [,1] [,2] [,3] [,4] [1,] 1 16 31 46 [2,] 2 17 32 47 [3,] 3 18 33 48 [4,] 4 19 34 49 [5,] 5 20 35 50 [6,] 6 21 36 51 [7,] 7 22 37 52 [8,] 8 23 38 53 [9,] 9 24 39 54 [10,] 10 25 40 55 [11,] 11 26 41 56 [12,] 12 27 42 57 [13,] 13 28 43 58 [14,] 14 29 44 59 [15,] 15 30 45 60 # compute column means colMeans(a) [1] 8 23 38 53 Hope this helps. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Tsjerk A. Wassenaar, Ph.D. post-doctoral researcher Molecular Dynamics Group * Groningen Institute for Biomolecular Research and Biotechnology * Zernike Institute for Advanced Materials University of Groningen The Netherlands __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Idea/package to linearize a curve along the diagonal?
I am trying to normalize some data. First I fitted a principal curve (using the LCPM package), but now I would like to apply a transformation so that the curve becomes a straight diagonal line on the plot. The data used to fit the curve would then be normalized by applying the same transformation to it. It is unclear to me what you mean by diagonal but I suspect what you're looking for is to locate projected points onto the unfolded curve. That is exactly what coordinates on the principal curve would give you. Sorry if I misunderstood your point, Yvonnick Noel University of Brittany, Rennes, France __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] diveMove 1.3.1
Version 1.3.1 of diveMove is now available on CRAN. Changes since previous version (1.2.9) are: o Improved formatting of code in vignette. Figure resolution reduced to satisfy package check requirements. o At least R 2.13.0 is required. o Dives occurring in trivial wet periods are now identified. o Improved validity checking for 'TDRcalibrate' objects. o 'TDRcalibrate' accessor methods now explicitly check and report that requested dives exist. o plotTDR() now conditionally generates initial plot, after preparing Tcl/Tk widgets, to accomodate for changes in R 2.14.2. Legend is plotted only if there is at least one level in the phase factor. Cheers, -- Sebastian P. Luque, Ph.D. Department of Biological Sciences University of Manitoba http://www.ucs.mun.ca/~sluque ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating 250 submatrices from a large single matrix with 2500 variables using loops
Hi Lazarus, You should use apply, not sapply. a =matrix(1:12, nrow=2,ncol=6,byrow=TRUE) b = array(a,c(2,2,3));b colMeans(b) f1=function(x) sum(x)/length(row(a.df[,1:2])) y3 - apply(b, 1, f1) It only gives one matrix with only two values, I expected 3 values. To apply the function on each submatrix, you have to apply it over the third index: y3 - apply(b, 3, f1) Cheers, Tsjerk -- Tsjerk A. Wassenaar, Ph.D. post-doctoral researcher Molecular Dynamics Group * Groningen Institute for Biomolecular Research and Biotechnology * Zernike Institute for Advanced Materials University of Groningen The Netherlands __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to find best model of time series?giving error
On 14-03-2012, at 07:22, sagarnikam123 wrote: yes but giving error t-read.table(file.choose()) t-ts(t) plot(t) Hit Return to see next plot: ht-HoltWinters(t) Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) : time series has no or less than 2 periods what should i do? Read HoltWinters help thoroughly. Your timeseries should have a frequency 1. So how about t - ts(t, start=??, frequency=4) Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with plot Grouped Bar Plot by using R
Please stop asking such basic questions on this list and start reading An Intro to R (ships with R) or any other beginning R tutorial. It seems to me to be impolite to pester this list for beginners' instructions without first having made at least a minimal effort to to familiarize yourself with R basics (in this case, basic plotting procedures). -- Bert On Tue, Mar 13, 2012 at 9:36 PM, R_beginner_starter cjyxiao...@gmail.com wrote: Thanks a lot, Jim. I get my desired output by using your R script at the end Yesterday was my mistake Apart from that, do you have any idea to plot a line graph/chart? My Input file is shown as below: Range Data1 Data2 1 38 37 2 38 37 3 38 37 4 37 37 5 37 37 6 37 37 7 37 37 8 37 37 9 37 37 10 37 37 11 37 37 12 37 37 13 37 37 14 37 37 15 37 37 16 37 37 17 37 37 18 37 37 19 37 37 20 37 37 21 37 36 22 37 36 23 37 36 24 37 36 25 37 36 26 37 36 27 36 36 28 36 36 29 36 36 30 36 36 31 36 36 32 36 36 33 36 36 34 36 36 35 36 36 36 36 36 37 36 36 38 36 36 39 36 36 40 36 36 Thanks for your further notice and advice :) -- View this message in context: http://r.789695.n4.nabble.com/Help-with-plot-Grouped-Bar-Plot-by-using-R-tp4448762p4471020.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating 250 submatrices from a large single matrix with 2500 variables using loops
?? Petr's solution is shorter and for large problems considerably faster... -- Bert On Wed, Mar 14, 2012 at 2:08 AM, Tsjerk Wassenaar tsje...@gmail.com wrote: Hi Lazarus, Sorry for my brevity before. I sent it from a phone. # Generate dummy data matrix x - matrix(1:100,nrow=5) # Rearrange into array; ten groups of two columns y - array(x,c(5,2,10)) # Average columns for each submatrix apply(y,c(1,3),mean) # Average per submatrix apply(y,3,mean) Hope it helps, Tsjerk On Wed, Mar 14, 2012 at 10:01 AM, Petr Savicky savi...@cs.cas.cz wrote: On Wed, Mar 14, 2012 at 03:22:39AM -0400, Lazarus Mramba wrote: Dear all, I have a large matrix with about 2500 variables, and 100 rows. I would like to calculate the means of the every 10 variables starting from 1:2500 and saving the results as a vector or matrix. How can I do that? Alternatively, How can I create 250 subset matrices in the order of variables 1:2500 in groups of 10 from the single matrix which had initially 2500 variables ? I guess I have to use a loop, but I can't figure out how. Hi. Try the following. I will use smaller parameters for simplicity. # a matrix 3 times 20 a - matrix(1:60, nrow=3, ncol=20) a [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [1,] 1 4 7 10 13 16 19 22 25 28 31 34 37 40 [2,] 2 5 8 11 14 17 20 23 26 29 32 35 38 41 [3,] 3 6 9 12 15 18 21 24 27 30 33 36 39 42 [,15] [,16] [,17] [,18] [,19] [,20] [1,] 43 46 49 52 55 58 [2,] 44 47 50 53 56 59 [3,] 45 48 51 54 57 60 #combine each 5 consecutive columns to a single column dim(a) - c(15, 4) a [,1] [,2] [,3] [,4] [1,] 1 16 31 46 [2,] 2 17 32 47 [3,] 3 18 33 48 [4,] 4 19 34 49 [5,] 5 20 35 50 [6,] 6 21 36 51 [7,] 7 22 37 52 [8,] 8 23 38 53 [9,] 9 24 39 54 [10,] 10 25 40 55 [11,] 11 26 41 56 [12,] 12 27 42 57 [13,] 13 28 43 58 [14,] 14 29 44 59 [15,] 15 30 45 60 # compute column means colMeans(a) [1] 8 23 38 53 Hope this helps. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Tsjerk A. Wassenaar, Ph.D. post-doctoral researcher Molecular Dynamics Group * Groningen Institute for Biomolecular Research and Biotechnology * Zernike Institute for Advanced Materials University of Groningen The Netherlands __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem installing RMySQL package!
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of AGGARWAL, NEERAJ (NEERAJ) Sent: 14 March 2012 05:14 To: r-help@r-project.org Subject: [R] Problem installing RMySQL package! I am facing issues while installing RMySQL package on windows(32 bit) installation of R-Project. I am getting the following warning messages. Warning messages: 1: running command 'C:/PROGRA~1/R/R-213~1.2/bin/i386/R CMD INSTALL -l C:/Program Files/R/R-2.13.2/library D:\DOCUME~1\nagga002\LOCALS~1\Temp\RtmpLZndlE/downloaded_packa ges/RMySQL_0.9-3.tar.gz' had status 1 2: In install.packages(RMySQL, type = source) : installation of package 'RMySQL' had non-zero exit status Is RTools something different from RProject. Read 'R installation and administration' in your R Help system. That will tell you what R Tools is/are and where to get them. In relation to accessing a MySQL database, you could also consider installing RODBC (which installs from binary unsinf install.packages()), registering your MySQL database as an ODBC data source in Windows and then using RODBC's query facilities. That certainly works for ordinary SELECTS, INSERTS and UPDATES, and does not require RMySQL. S*** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Apply a loop containing a function on a list
Le mercredi 14 mars 2012 à 00:51 -0700, ali_protocol a écrit : Hi all, I want to do this: B.list$aa= (a loop containing My.fun acting on the reults of second function on a A.list$aa)) or, overally B.list$aa = function (A.list$aa) B.list and A.list has many sublists aa, ab and Is there a way I can apply the function and loop on all sublists of A.list and get B.list? Please provide a small example, you can easily create two lists to illustrate your point. It's hard to help without that, it would require us mocking up an example for you, and we might get it wrong. Cheers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Creating polygons from scattered points
Hello, I have a distribution dataset for species consisting of xy coordinates at the 1km resolution, with only presence data. So a simplified example of a species distribution might be: y - rbind(as.integer(rnorm(100,50,20)), as.integer(rnorm(200,100,30)), as.integer(rnorm(100,180,15))) x - rbind(as.integer(rnorm(200,50,20)), as.integer(rnorm(200,100,20)), as.integer(rnorm(100,200,15))) plot(y~x) I would like to create polygons for each species distribution, where if an island is present (as I have tried to show in the example), it would be a seperate polygon, and the jagged edges of coastlines etc are maintained. I have spent ages trying to find a package that will allow me to convert scattered point distributions to polygons but haven't found anything that works, the functions I have found require the data already to be in the format where the only xy coordinates present are the outline of the polygon. Can anyone please recommend a function I can use here, or suggest a way of extracting the outline points? I have tried this manually but cannot seem to write a code that will effectively take account of jagged edges and islands. Thanks very much for your help, Louise. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Moore-Penrose Generalized determinant?
Is there a function in R to calculate the generalized determinant of a singular matrix? - similar to the ginv() used to compute the generalized inverse. I can't seem to find any R related posts at all. Thanks in advance, Sean O'Riordain Trinity College Dublin -- View this message in context: http://r.789695.n4.nabble.com/Moore-Penrose-Generalized-determinant-tp4471629p4471629.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] multi-histogram plotting
It's easier to do log plots as plot(h$density, log = L) where L is one of x, y, or xy as you choose. This is well documented. Michael On Wed, Mar 14, 2012 at 12:02 AM, Sam Steingold s...@gnu.org wrote: * David Winsemius qjvafrz...@pbzpnfg.arg [2012-03-13 17:53:14 -0400]: On Mar 13, 2012, at 5:33 PM, Sam Steingold wrote: I can, of course, plot log(h$density), but then the number labels will be wrong. You could try apply a log transform to the appropriate component of the h object and using barplot to display the results. that's what I said above: plot log(h$density). However, the ordinate will be labeled with log values, not the original values. how do I get the log ticks on the ordinate? -- Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000 http://www.childpsy.net/ http://jihadwatch.org http://www.memritv.org http://dhimmi.com http://memri.org http://pmw.org.il http://truepeace.org Profanity is the one language all programmers know best. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshaping a dataset for a network
You can't have empty spots like that in an array. One choice would be to fill them with NAs: library(plyr) do.call(rbind.fill.matrix,lapply(split(b,a), t)) Michael On Wed, Mar 14, 2012 at 4:01 AM, Marco Guerzoni marco.guerz...@unito.it wrote: Thank you fro the reply. I managed to arrive till here, then I would like to have it in matrix where the $1 $2...$5 are the first column. Il 3/13/2012 8:15 PM, William Dunlap ha scritto: Is the following what you want? a- c(1,2,3,4,4,4,5,5) b- c(11,7,4,9,8,3,12,4) split(b, a) $1 [1] 11 $2 [1] 7 $3 [1] 4 $4 [1] 9 8 3 $5 [1] 12 4 Here I did c - split(b, a) d - do.call(rbind,c) and I get [,1] [,2] [,3] 1 11 11 11 2 7 7 7 3 4 4 4 4 9 8 3 5 12 4 12 Instead of what I would like: [,1] [,2] [,3] 1 11 2 7 3 4 4 9 8 3 5 12 4 A solution could be rbind.fill , which does not seem to work with list. thanks Marco Guerzoni, Department of Economics University of Turin Note that your df-cbind(a,b) produces a matrix, not the data.frame that your df suggests you want. Use df-data.frame(a,b) to make a data.frame. Then you could do with(df, split(a,b)) to operate on the a and b in the data.frame df. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Marco Guerzoni Sent: Tuesday, March 13, 2012 10:51 AM To: r-help@r-project.org Subject: [R] reshaping a dataset for a network dear all, apologizes for bothering with a probably stupid question but I really don' t know how to proceed. I have a dataset which look like df a- c(1,2,3,4,4,4,5,5) b- c(11,7,4,9,8,3,12,4) df-cbind(a,b) I would like to have one which looks like this: a 1 11 2 7 3 4 4 9 8 3 5 12 4 a are vertex of a network, b the edges. In the data the lenght of a is about 5 I read several posts about reshape, reshape2, split, ldply but I couldn't manage to do it. The problem seems to be that the is not a real panel. Any help would be really appreciated, my best regards Marco __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem installing RMySQL package!
In addition to Dr. Ellison's sound advice, as the link says: follow the provided link, go to a CRAN mirror (http://cran.r-project.org/mirrors.html), click download for windows and Rtools will be available. Michael On Wed, Mar 14, 2012 at 1:14 AM, AGGARWAL, NEERAJ (NEERAJ) neeraj.aggar...@alcatel-lucent.com wrote: I am facing issues while installing RMySQL package on windows(32 bit) installation of R-Project. I am getting the following warning messages. Warning messages: 1: running command 'C:/PROGRA~1/R/R-213~1.2/bin/i386/R CMD INSTALL -l C:/Program Files/R/R-2.13.2/library D:\DOCUME~1\nagga002\LOCALS~1\Temp\RtmpLZndlE/downloaded_packages/RMySQL_0.9-3.tar.gz' had status 1 2: In install.packages(RMySQL, type = source) : installation of package 'RMySQL' had non-zero exit status It seems many people faced the issue and some got it resolved manipulating with some jars. I got one solution from - http://stackoverflow.com/questions/4785933/adding-rmysql-package-to-r-fails/5236954#5236954 The basic process is described herehttp://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL, but there are several hints, So I will describe the whole solution(please change the R version and paths if needed): 1. Install latest RTools from herehttp://www.murdoch-sutherland.com/Rtools/ 2. install MySQL or header and library files of mysql 3. create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line likeMYSQL_HOME=C:/mysql (path to your mysql files) 4. copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies. 5. copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32 directory. 6. run install.packages('RMySQL',type='source') and wait while compilation will end. This worked for me on Windows 7 64 bit, so there should be no problems with 32 bit versions II tried the above steps, but I am still facing problems. Is RTools something different from RProject. I did not find anything by the name RTools at the given link? Regards, Neeraj Aggarwal [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating polygons from scattered points
This might be a question for the R-SIG-Geo or R-SIG-Ecology lists. Best, Michael On Wed, Mar 14, 2012 at 7:13 AM, Louise Mair lm...@york.ac.uk wrote: Hello, I have a distribution dataset for species consisting of xy coordinates at the 1km resolution, with only presence data. So a simplified example of a species distribution might be: y - rbind(as.integer(rnorm(100,50,20)), as.integer(rnorm(200,100,30)), as.integer(rnorm(100,180,15))) x - rbind(as.integer(rnorm(200,50,20)), as.integer(rnorm(200,100,20)), as.integer(rnorm(100,200,15))) plot(y~x) I would like to create polygons for each species distribution, where if an island is present (as I have tried to show in the example), it would be a seperate polygon, and the jagged edges of coastlines etc are maintained. I have spent ages trying to find a package that will allow me to convert scattered point distributions to polygons but haven't found anything that works, the functions I have found require the data already to be in the format where the only xy coordinates present are the outline of the polygon. Can anyone please recommend a function I can use here, or suggest a way of extracting the outline points? I have tried this manually but cannot seem to write a code that will effectively take account of jagged edges and islands. Thanks very much for your help, Louise. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem installing RMySQL package!
On Wed, Mar 14, 2012 at 1:14 AM, AGGARWAL, NEERAJ (NEERAJ) neeraj.aggar...@alcatel-lucent.com wrote: I am facing issues while installing RMySQL package on windows(32 bit) installation of R-Project. I am getting the following warning messages. Warning messages: 1: running command 'C:/PROGRA~1/R/R-213~1.2/bin/i386/R CMD INSTALL -l C:/Program Files/R/R-2.13.2/library D:\DOCUME~1\nagga002\LOCALS~1\Temp\RtmpLZndlE/downloaded_packages/RMySQL_0.9-3.tar.gz' had status 1 2: In install.packages(RMySQL, type = source) : installation of package 'RMySQL' had non-zero exit status It seems many people faced the issue and some got it resolved manipulating with some jars. I got one solution from - http://stackoverflow.com/questions/4785933/adding-rmysql-package-to-r-fails/5236954#5236954 The basic process is described herehttp://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL, but there are several hints, So I will describe the whole solution(please change the R version and paths if needed): 1. Install latest RTools from herehttp://www.murdoch-sutherland.com/Rtools/ 2. install MySQL or header and library files of mysql 3. create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line likeMYSQL_HOME=C:/mysql (path to your mysql files) 4. copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies. 5. copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32 directory. 6. run install.packages('RMySQL',type='source') and wait while compilation will end. This worked for me on Windows 7 64 bit, so there should be no problems with 32 bit versions II tried the above steps, but I am still facing problems. Is RTools something different from RProject. I did not find anything by the name RTools at the given link? The above description is outdated if you are using the latest version of RMySQL. Install Rtools from http://cran.r-project.org/bin/windows/Rtools and then look at the Windows section of the Installation Info link at http://cran.r-project.org/package=RMySQL (which is the installation information that comes with the package itself). -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating polygons from scattered points
No time to really think about this, but: a) to convert scattered point distributions to polygons you might look at convex hulls; e.g. convhulln {geometry} b) to identify islands some kind of cluster analysis Hope that helps a little. KJ Louise Mair lm...@york.ac.uk wrote in message news:camkzt57pep1zkpgm2dg5tn6r0p-_o5tf+wsnurxdohf8zvm...@mail.gmail.com... Hello, I have a distribution dataset for species consisting of xy coordinates at the 1km resolution, with only presence data. So a simplified example of a species distribution might be: y - rbind(as.integer(rnorm(100,50,20)), as.integer(rnorm(200,100,30)), as.integer(rnorm(100,180,15))) x - rbind(as.integer(rnorm(200,50,20)), as.integer(rnorm(200,100,20)), as.integer(rnorm(100,200,15))) plot(y~x) I would like to create polygons for each species distribution, where if an island is present (as I have tried to show in the example), it would be a seperate polygon, and the jagged edges of coastlines etc are maintained. I have spent ages trying to find a package that will allow me to convert scattered point distributions to polygons but haven't found anything that works, the functions I have found require the data already to be in the format where the only xy coordinates present are the outline of the polygon. Can anyone please recommend a function I can use here, or suggest a way of extracting the outline points? I have tried this manually but cannot seem to write a code that will effectively take account of jagged edges and islands. Thanks very much for your help, Louise. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to extend a slot of a class?
Hej hej, is there a way to extend the SpatialPointsDataFrame data slot?This is the structure of an object of it: str(coord) Formal class 'SpatialPointsDataFrame' [package sp] with 5 slots ..@ data :'data.frame': 214 obs. of 2 variables: .. ..$ location.long: num [1:214] -79.8 -79.8 -79.8 -79.8 -79.8 ... .. ..$ location.lat : num [1:214] 9.16 9.16 9.16 9.16 9.16 ... ..@ coords.nrs : num(0) ..@ coords : num [1:214, 1:2] -79.8 -79.8 -79.8 -79.8 -79.8 ... .. ..- attr(*, dimnames)=List of 2 .. .. ..$ : NULL .. .. ..$ : chr [1:2] location.long location.lat ..@ bbox : num [1:2, 1:2] -79.84 9.16 -79.84 9.17 .. ..- attr(*, dimnames)=List of 2 .. .. ..$ : chr [1:2] location.long location.lat .. .. ..$ : chr [1:2] min max ..@ proj4string:Formal class 'CRS' [package sp] with 1 slots .. .. ..@ projargs: chr NA data is a data.frame including the information of long and lat location. I would like to have there a third information: time (but as POSIXct). Is there an elegant way to do this? Best, marco [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ROC Analysis
Hi, Pascal, I tried to use your method which functions but the values of the abscissa are not good. When I talked about “value”, I wanted mean the values of my starting dataset that I have classified into two classes positive and negative classes, such as this : Value Status TPF TNF 10001 487 0 852 1 927 1 799 1 369 0 … … And for each value of my dataset, I want the tpf and tnf. With your method, I have an abscissa which has values between 0 and 1. All the best, Camille - -- Camille Leclerc, Master student Lab ESE, UMR CNRS 8079 Univ Paris-Sud Bat 362 F-91405 Orsay Cedex FRANCE -- View this message in context: http://r.789695.n4.nabble.com/ROC-Analysis-tp4469203p4471300.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plm function
Dear Sir/ Madam, I am writing about the panel data for my bachelor degree. I would really appreciate if You could help dealing with R functions. I am trying to estimate the panel data lm model with plm function. When i include 3dummy variables into the regression it dont appear in the sumarry of the model, but when i estimate a simple lm model it appears. Why is it so? What should i do to estimate the statistics for those dummy variables? Thank You. Ieva [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] beginner's loop issue
Thank you all for your helpful comments! I solved my problem by creating an empty matrix before the loop and adjusting the loop itself, this is the code: size - dim(input) out - matrix('',nrow =size[1], ncol = 9) for (i in 1:nrow(input)) { out[i,1:3] - unlist(MyFunction(input[i,1],input[i,2], input[i,3]) out[i,4:6] - unlist(MyFunction(input[i,5],input[i,7], input[i,6]) out[i,7:9] - unlist(MyFunction(input[i,8],input[i,10], input[i,9]) } It's probably not the most efficient way of doing it but it gives me the desired output matrix... Thanks for pointing me to this pdf R inferno pdf, I had an old version of it.. I'm, starting to use R again after long time and this is a very useful guide! All the best Ale -- View this message in context: http://r.789695.n4.nabble.com/beginner-s-loop-issue-tp4469514p4471352.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sum results in a matrix
thank you It is working, a question in the wake of the array. with the following code I am creating a data frame to store the data without repeating the code is working. The question is the best way to do this process in R tab-NULL for(i in 1: nrow(res4)) { for(j in i:nrow(res4)) { #print(paste(i,-,j,-,res4[i,j])) temp-data.frame(i,j,res4[i,j]) tab-rbind(tab,temp) } } tab i j res4.i..j. 1 1 1 0 2 1 2 21 3 1 3 0 4 1 4 0 5 1 5 0 6 1 6 0 7 1 7 0 8 2 2 0 -- View this message in context: http://r.789695.n4.nabble.com/Sum-results-in-a-matrix-tp4468936p4471368.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshaping a dataset for a network
thank you very much I had managed with df - data.frame(a,b) m - lapply(split(df, df$a), function(x) x$b) n - max(sapply(m, length)) a - t(sapply(m, function (x) c(x, rep(NA, n - length(x) but your solution is much more elegant. best regards Marco Il 3/14/2012 1:54 PM, R. Michael Weylandt ha scritto: You can't have empty spots like that in an array. One choice would be to fill them with NAs: library(plyr) do.call(rbind.fill.matrix,lapply(split(b,a), t)) Michael On Wed, Mar 14, 2012 at 4:01 AM, Marco Guerzonimarco.guerz...@unito.it wrote: Thank you fro the reply. I managed to arrive till here, then I would like to have it in matrix where the $1 $2...$5 are the first column. Il 3/13/2012 8:15 PM, William Dunlap ha scritto: Is the following what you want? a- c(1,2,3,4,4,4,5,5) b- c(11,7,4,9,8,3,12,4) split(b, a) $1 [1] 11 $2 [1] 7 $3 [1] 4 $4 [1] 9 8 3 $5 [1] 12 4 Here I did c- split(b, a) d- do.call(rbind,c) and I get [,1] [,2] [,3] 1 11 11 11 2777 3444 4983 5 124 12 Instead of what I would like: [,1] [,2] [,3] 1 11 27 34 4983 5 124 A solution could be rbind.fill , which does not seem to work with list. thanks Marco Guerzoni, Department of Economics University of Turin Note that your df-cbind(a,b) produces a matrix, not the data.frame that your df suggests you want. Use df-data.frame(a,b) to make a data.frame. Then you could do with(df, split(a,b)) to operate on the a and b in the data.frame df. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Marco Guerzoni Sent: Tuesday, March 13, 2012 10:51 AM To: r-help@r-project.org Subject: [R] reshaping a dataset for a network dear all, apologizes for bothering with a probably stupid question but I really don' t know how to proceed. I have a dataset which look like df a- c(1,2,3,4,4,4,5,5) b- c(11,7,4,9,8,3,12,4) df-cbind(a,b) I would like to have one which looks like this: a 1 11 2 7 3 4 4 9 8 3 5 12 4 a are vertex of a network, b the edges. In the data the lenght of a is about 5 I read several posts about reshape, reshape2, split, ldply but I couldn't manage to do it. The problem seems to be that the is not a real panel. Any help would be really appreciated, my best regards Marco __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] not saving plot with resizable size?
i want to save plots in batch mode(100 plots in single code) in resizable mode which format should i use,i m working on windows savePlot(zatka,type=pdf,device=dev.cur()) Error in savePlot(zatka, type = pdf, device = dev.cur()) : can only copy from 'windows' devices -- View this message in context: http://r.789695.n4.nabble.com/not-saving-plot-with-resizable-size-tp4471520p4471520.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R course: London, Monday 18th - Friday 22nd June 2012.
r-help readers may be interested in our week-long summer school 'Introduction to R'. Further details including links to the course materials from last year and the application form are at: http://www.kcl.ac.uk/schools/summerschool/si/sgdp/course2/ The course is presented by the MRC Social, Genetic and Developmental Psychiatry Research Centre at the Institute of Psychiatry in London (UK). Because the emphasis is on fundamentals, the course may be of interest to people from diverse fields. There are practical sessions paired with each lecture. Leo Schalkwyk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Real-Time data transfer from Excel to R
Hi All I receive through DDE ,real time data from an external supplier on an Excel 2003 sheet. I use R as platform to make backtest trading and prepare trade. My question : Is existing a solution to transfer real-time data from Excel to R? Such transfer keeping the streaming condition. I don't intend to open an account to IB. And I don't want make backtest on Excel,using R as calculator Thanks for help Burcy -- View this message in context: http://r.789695.n4.nabble.com/Real-Time-data-transfer-from-Excel-to-R-tp4471569p4471569.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sort list
I appreciate the reading Thank you. May i ask one final question. If i have: matrix: var1var2 var3 cell1x x x cell2x x x cell3x x x cell4 . . . . cell100 and: vector1 - c(cell1, cell5,cell19, cell50, cell70) your_data$mycells - factor(your_data$cells %in% vector1, c(Special, NotSpecial)) So my output will be something like: [25] SpecialSpecialSpecialSpecialSpecialSpecial [31] SpecialNotSpecial NotSpecial NotSpecial NotSpecial NotSpecial [37] NotSpecial NotSpecial NotSpecial NotSpecial is there a way to plot the data so that my Special cells are plotted on top of my not special cells. The reason is my data may have 1 not special points,and i may have 5 special cells, I find I'm not able to see where they are on my plot because they are being covered by my not special cells :( I have been looking around for order of factors plotted , 'order of levels, order of factor levels, is this on the right track or can it even be done? Syb On Wed, Mar 14, 2012 at 2:04 PM, sybil kennelly sybilkenne...@gmail.comwrote: I appreciate the reading Thank you. May i ask one final question. If i have: matrix: var1var2 var3 cell1x x x cell2x x x cell3x x x cell4 . . . . cell100 and: vector1 - c(cell1, cell5,cell19, cell50, cell70) your_data$mycells - factor(your_data$cells %in% vector1, c(Special, NotSpecial)) So my output will be something like: [25] SpecialSpecialSpecialSpecialSpecialSpecial [31] SpecialNotSpecial NotSpecial NotSpecial NotSpecial NotSpecial [37] NotSpecial NotSpecial NotSpecial NotSpecial is there a way to plot the data so that my Special cells are plotted on top of my not special cells. The reason is my data may have 1 not special points,and i may have 5 special cells, I find I'm not able to see where they are on my plot because they are being covered by my not special cells :( I have been looking around for order of factors plotted , 'order of levels, order of factor levels, is this on the right track or can it even be done? Syb On Tue, Mar 13, 2012 at 12:29 PM, Joshua Wiley jwiley.ps...@gmail.comwrote: On Tue, Mar 13, 2012 at 5:15 AM, sybil kennelly sybilkenne...@gmail.com wrote: Thanks Josh. I'm quite new, just wondering re:factor levels? In this example (shamelessly stolen from the internet): schtyp [1] 0 0 1 0 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 0 schtyp.f - factor(schtyp, labels = c(private, public)) schtyp.f [1] private private public private private private public private public [10] private public public public public private private public public [19] public private Levels: private public in my data i have a table: var1var2 var3 cell1x x x cell2x x x cell3x x x cell4 . . . . cell100 and i have a subset of those cells that are interesting to me as a list of data list1 = [cell1, cell5,cell19, cell50, cell70] is it possible to create (similar to above): schtyp.f - factor(schtyp, labels = c(special, normal)) Sure. Again, probably better to have cells of interest in a vector, not a list a la: list1 - c(cell1, cell5,cell19, cell50, cell70) your_data$mycells - factor(your_data$cells %in% list1, c(Special, NotSpecial)) basically compares the cells to those in your list and returns TRUE/FALSE, which is then converted to a factor, labeled, and stored. If you are just starting, some background reading will help. Here are some suggestions: 1) Go here: http://www.burns-stat.com/pages/tutorials.html and read the tutorials for R -- Beginning (this should not take more than 1 day). 2) Sit down and read: http://cran.r-project.org/doc/manuals/R-intro.pdf through Appendix A (for now you can probably skip the rest of the appendices). That will probably take another entire day or so. 3) Head back to Patrick Burn's website: http://www.burns-stat.com/pages/tutorials.html and read the intermediate guide, The R Inferno (1-3 days depending if you can read for 8 hours straight or not) Cheers, Josh so that when i plot this data, i can color the items in list1 as one color (eg all the special cells are red), and the rest of the items as a second color (eg all the other cells are black/blue)? Syb On Tue, Mar 13, 2012 at 11:48 AM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi Sybil, You cannot turn a list into a factor. You could do: cell_data -c('cell1','cell2') factor_list - factor(cell_data) or if you already have a list, unlist() or as.vector() may convert it into a vector that you can then convert to a factor. Cheers, Josh On Tue, Mar 13, 2012 at 4:29 AM, sybil kennelly sybilkenne...@gmail.com
[R] geom_plot creates Area Instead Of Lines
Hi, I have created a large (?) data frame. I have one variable to plot, lets call it X. further X has been observed under conditions Y, Z. And the observation took place at times T (0:10e5). Now my data frame D consists of x,y,z,t each corresponding to the combination of X, Y, Z and T. I would like to create different plots and use this: h - ggplot(D, aes(y=x, x=t)) h + geom_line(data=subset(subset(D,y=someThing),z=thingSome)) +geom_line(data=subset(subset(D,y=someThingElse),z=ThingSomeElse)); Now the issue is that T is a vector of repeated sequences from 0 to 10e5 (something like 1 2 3 1 2 3 1 2 3). This way X corresponds to the correct time of measurement FOR MANY REPEATED MEASUREMENTS. From the above code I get something very similar to what i want – only that the individual lines for X vs T which I was expecting seem to be just one coloured area between Xmax and Xmin for each T. http://r.789695.n4.nabble.com/file/n4471583/Rpot.png What I would have liked is something like a cloud of lines, similar to what I get when I convert the data into a matrix (why do I not just use a matrix? I come from MATLAB and this seems natural, however, my data is large and a data frame seems to be an advantageous way to handle that). On side note, generating this “area” plot takes AGES, idk where I got so inefficient in my approach or whether this is unavoidable, but this is really … upsetting. Any help is very much appreciated. K -- View this message in context: http://r.789695.n4.nabble.com/geom-plot-creates-Area-Instead-Of-Lines-tp4471583p4471583.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] list factoring
Hi Guys, this is actually a thread of emails, but for some reason, even though i am a member, it's withholding my email so i said i would try it this route instead!... I appreciate the reading Thank you. If i have: matrix: var1var2 var3 cell1x x x cell2x x x cell3x x x cell4 . . . . cell100 and: vector1 - c(cell1, cell5,cell19, cell50, cell70) your_data$mycells - factor(your_data$cells %in% vector1, c(Special, NotSpecial)) So my output will be something like: [25] SpecialSpecialSpecialSpecialSpecialSpecial [31] SpecialNotSpecial NotSpecial NotSpecial NotSpecial NotSpecial [37] NotSpecial NotSpecial NotSpecial NotSpecial is there a way to plot the data so that my Special cells are plotted on top of my not special cells. The reason is my data may have 1 not special points,and i may have 5 special cells, I find I'm not able to see where they are on my plot because they are being covered by my not special cells :( I have been looking around for order of factors plotted , 'order of levels, order of factor levels, is this on the right track or can it even be done? Syb -- View this message in context: http://r.789695.n4.nabble.com/list-factoring-tp4471931p4471931.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] logical test not functioning correctly on zoo series...what the hell?
Here's the raw data I'm working with (will be available temporarily): http://dl.dropbox.com/u/41922443/dataout_2471_843.csv Next, here's the code I want to impose (error that I'm seeing SHOULD reproduce on your shell when script is executed...btw using Ubuntu Linux 11.10 if that makes a difference): http://pastebin.com/LDNw8UT0 The issue specifically is the last line of code in which I want to print out any value greater than 0. The outputs that I'm getting, however, are printing out 0's down the columns. I've tried various methods assuming various theories, read the R manual via ? for different possible solutions, Googled stuff, tried the ifelse function which produces the same error, tried creating logical vectors to get a better visual of what the process is, tried doing all of the above on a small sample data set (which actually works correctly for some reason, but doesn't work on the actual raw data), and basically have done a lot of research and trial and error before posting on here. Help is much appreciated. Thank you. P.S. I hope I asked this correctly on the forum (putting reproducible code that reproduces the error, etc.). If I made some noob mistake, I apologize in advance so please don't be mad at me. I will clarify if necessary. -- View this message in context: http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4471654.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] random effect of species in lme on slope taking into account two variables
Hi! Just wondering how you would change this code so i can look at the random effect of species on slopes of effect of logM (body mass) and K (temperature) together. I did this so far: model1-lme(logSSP~logM + K,random=~1|species,data=data1) #random effect of spp on intercept model2-lme(logSSP~logM + K,random=~K|species,data=data1) #random effect of spp on slope K model3-lme(logSSP~logM + K,random=~logM|species,data=data1) #random effect of spp on slope logM The one I now want is: model4-lme(logSSP~logM + K,random=~logM|species,K|species,data=data1) #random effect of spp on both slopes of logM and K # but this code doesn't work so how do i change the code to have a random effect of species on slopes of logM and K together??? Please help :( Harkiran [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to calculate AIC value from below values using time series model
t -0.15264004 0.056076439 -0.07276116 -0.00917326 -0.02069089 -0.00416232 -0.07225855 -0.02654577 -0.06131410 -0.09380202 0.057414014 -0.05239976 0.014397612 0.016145161 -0.00670587 0.018696335 0.036943654 -0.02450233 0.031161705 0.006513503 -0.02892329 -0.00831519 -0.00877744 -0.00634399 -0.02612019 -0.02531800 -0.01435533 0.011148840 -0.01893775 0.029859128 0.029878797 -0.00125987 0.031404385 0.035127606 -0.00191775 0.059797202 -0.03268047 -0.06026960 -0.02216465 -0.08145612 -0.02772806 -0.03171683 -0.02842562 -0.11807898 -0.01457311 -0.12612482 0.409631265 -0.06375234 if i have 200 such t variable (which have time observations ranging from 100-400) want to select best model,how should i select it? -- View this message in context: http://r.789695.n4.nabble.com/how-to-calculate-AIC-value-from-below-values-using-time-series-model-tp4472014p4472014.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to find best model of time series? calculate aic value, if i have
yes,but i want AIC value to calculate for below value, using frequency =1 in ts() function t -0.15264004 0.056076439 -0.07276116 -0.00917326 -0.02069089 -0.00416232 -0.07225855 -0.02654577 -0.06131410 -0.09380202 0.057414014 -0.05239976 0.014397612 0.016145161 -0.00670587 0.018696335 0.036943654 -0.02450233 0.031161705 0.006513503 -0.02892329 -0.00831519 -0.00877744 -0.00634399 -0.02612019 -0.02531800 -0.01435533 0.011148840 -0.01893775 0.029859128 0.029878797 -0.00125987 0.031404385 0.035127606 -0.00191775 0.059797202 -0.03268047 -0.06026960 -0.02216465 -0.08145612 -0.02772806 -0.03171683 -0.02842562 -0.11807898 -0.01457311 -0.12612482 0.409631265 -0.06375234 in short, i want to know which is best model if i have this type of vectors(t) 200,each having 400 observations at respective time i.e. 1,2,3,4.400 -- View this message in context: http://r.789695.n4.nabble.com/how-to-find-best-model-of-time-series-tp4469296p4471664.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rolling regressions with sample extended one period at a time
Hi, I took a look at the documentation concerning rollapply and it doesnt seem to be the command I need. Just to be more clear, on an initial sample of 80 observations I want to perform a probit regression and save the fitted probabilities in a vector. Subsequently another probit is run on the sample 1-81 with relative save of the fitted probabilities. And so again for the sample 1-82, 1-83, 1-84 etc... through the end of the sample. Does rollapply allow me to do this? P. -- View this message in context: http://r.789695.n4.nabble.com/Rolling-regressions-with-sample-extended-one-period-at-a-time-tp4470316p4471995.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] not saving plot with resizable size?
Just plot directly to your desired output device and don't try to copy. pdf(outfilename.pdf) # lots of plots dev.off() and everything will come out in a single pdf Michael On Wed, Mar 14, 2012 at 6:44 AM, sagarnikam123 sagarnikam...@gmail.com wrote: i want to save plots in batch mode(100 plots in single code) in resizable mode which format should i use,i m working on windows savePlot(zatka,type=pdf,device=dev.cur()) Error in savePlot(zatka, type = pdf, device = dev.cur()) : can only copy from 'windows' devices -- View this message in context: http://r.789695.n4.nabble.com/not-saving-plot-with-resizable-size-tp4471520p4471520.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] aggregate
Dear all I am having a vector with large length and I would like to ask you if I can aggregate the values by constant sized windows. For example for the following vector, I would like to take 30 points until the end and find their mean. myData-seq(1:10) c(mean(myData[1:30]),mean(myData[31:60])) #...and so one until the end [1] 15.5 45.5 I have searched in the R documentation and I found the aggregate but it seems to operate on data.frames. It also has this by argument where I tried to set it to 30 but it expects there a list rather than a numeric value. Could you please help me ? I would like to thank you in advance for your help B.R Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] where I can find more color names or color definition?
hi everyone . Now I want to draw several lines in one frame.And it seems needs more colors except for blue red,black .Where can i found these color name or define some new color ?thank you . -- TANG Jie Email: totang...@gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] gam - Y axis probability scale with confidence/error lines
Hello, How do I plot a gam fit object on probability (Y axis) vs raw values (X axis) axis and include the confidence plot lines? Details... I'm using the gam function like this: l_yx[,2] = log(l_yx[,2] + .0004) fit - gam(y~s(x),data=as.data.frame(l_yx),family=binomial) And I want to plot it so that probability is on the Y axis and values are on the X axis (i.e. I don't want log likelihood on the Y axis or the log of my values on my X axis): xx - seq(min(l_yx[,2]),max(l_yx[,2]),len=101) plot(xx,predict(fit,data.frame(x=xx),type=response),type=l,xaxt=n,xlab=Churn,ylab=P(Top Performer)) at - c(.001,.01,.1,1,10) # -- I'd also like to generalize this rather than hard code the numbers axis(1,at=log(at+ .0004),label=at) So far, using the code above, everything looks the way I want. But that does not give me anything information on variability/confidence/certainty. How do I get the dash plots from this: plot(fit) ...on the same scales as above? Related question: how do get the dashed values out of the fit object so I can do 'stuff' with it? Thanks, Ben PS - thank you Patrick for your help previously. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sum results in a matrix
On Wed, Mar 14, 2012 at 02:28:22AM -0700, RMSOPS wrote: thank you It is working, a question in the wake of the array. with the following code I am creating a data frame to store the data without repeating the code is working. The question is the best way to do this process in R tab-NULL for(i in 1: nrow(res4)) { for(j in i:nrow(res4)) { #print(paste(i,-,j,-,res4[i,j])) temp-data.frame(i,j,res4[i,j]) tab-rbind(tab,temp) } } Hi. Try the following. # create a matrix res4 - matrix(1:12, nrow=3, ncol=4) d - dim(res4) ind - expand.grid(i=1:d[1], j=1:d[2]) cbind(ind, res4=c(res4)) i j res4 1 1 11 2 2 12 3 3 13 4 1 24 5 2 25 6 3 26 7 1 37 8 2 38 9 3 39 10 1 4 10 11 2 4 11 12 3 4 12 Hope this helps. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Moore-Penrose Generalized determinant?
If the matrix is singular, the determinant of the matrix and its M-P inverse are both zero. Sean O'Riordain sean...@acm.org Sent by: r-help-boun...@r-project.org 03/14/2012 07:41 AM To r-help@r-project.org cc Subject [R] Moore-Penrose Generalized determinant? Is there a function in R to calculate the generalized determinant of a singular matrix? - similar to the ginv() used to compute the generalized inverse. I can't seem to find any R related posts at all. Thanks in advance, Sean O'Riordain Trinity College Dublin -- View this message in context: http://r.789695.n4.nabble.com/Moore-Penrose-Generalized-determinant-tp4471629p4471629.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with expression
Hi all, I still fail to plot an axis title with the following expression: plot(0,xlab=expression('(SOC [' * kgm^{-2} * '])' * ^{-2})) the xlab should look like: (SOC [kgm^2])^0.25 with an out bracket and a superscript. Thanks for your advice. Thomas [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to use a saved SVM model from e1071
Hello, I have an SVM model previously calibrated using libsvm R implementation from the e1071 package. I would like to use this SVM to predict values, from a Java program. I first tried to use jlibsvm and the standard java implementation of libsvm, without success. Thus, I am now considering writing data in files from my Java code, calling an R program to predict values, then gather the predicted values in Java. The problem is that I do not know how to re-use the model saved using the write.svm() function, since there is no read.svm() function. I read the following message in the mailing archive, stating that I may use the save and load methods built in R : http://www.mail-archive.com/r-help@r-project.org/msg64428.html Still, I am not sure how to pre-process the data and to post-process the results. Since write.svm() writes .scale and .ysale files as well as an svm file, I figure that the scaling data is included in the svm object. Does that mean that I do not have to worry about scaling my data and unscaling the results provided by the predict function on a model reloaded using save/load ? I am asking this because I previously succeeded in loading the svm model from libsvm in Java, but the results using unscaled data were obviously wrong. Thanks in advance, Thomas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] aggregate
On Wed, Mar 14, 2012 at 07:46:40AM -0700, Alaios wrote: Dear all I am having a vector with large length and I would like to ask you if I can aggregate the values by constant sized windows. For example for the following vector, I would like to take 30 points until the end and find their mean. myData-seq(1:10) c(mean(myData[1:30]),mean(myData[31:60])) #...and so one until the end [1] 15.5 45.5 Hi. Try the following. myData - 1:100 gr - ceiling((1:length(myData))/30) c(tapply(myData, gr, FUN=mean)) 1234 15.5 45.5 75.5 95.5 Hope this helps. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] where I can find more color names or color definition?
apropos(color) ?colors colors() Michael On Wed, Mar 14, 2012 at 10:55 AM, Jie Tang totang...@gmail.com wrote: hi everyone . Now I want to draw several lines in one frame.And it seems needs more colors except for blue red,black .Where can i found these color name or define some new color ?thank you . -- TANG Jie Email: totang...@gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to find best model of time series? calculate aic value, if i have
On 14-03-2012, at 13:00, sagarnikam123 wrote: yes,but i want AIC value to calculate for below value, using frequency =1 in ts() function t -0.15264004 0.056076439 -0.07276116 -0.00917326 -0.02069089 -0.00416232 -0.07225855 -0.02654577 -0.06131410 -0.09380202 0.057414014 -0.05239976 0.014397612 0.016145161 -0.00670587 0.018696335 0.036943654 -0.02450233 0.031161705 0.006513503 -0.02892329 -0.00831519 -0.00877744 -0.00634399 -0.02612019 -0.02531800 -0.01435533 0.011148840 -0.01893775 0.029859128 0.029878797 -0.00125987 0.031404385 0.035127606 -0.00191775 0.059797202 -0.03268047 -0.06026960 -0.02216465 -0.08145612 -0.02772806 -0.03171683 -0.02842562 -0.11807898 -0.01457311 -0.12612482 0.409631265 -0.06375234 in short, i want to know which is best model if i have this type of vectors(t) 200,each having 400 observations at respective time i.e. 1,2,3,4.400 You seem to be changing what you want. First you wanted seasonal decomposition, you got answers and now you've changed the goal(post). Well my final answer is look at the forecast package. Maybe auto.arima is what you want. Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] where I can find more color names or color definition?
Hi, One way would be to type colors() and choose your favorite(s) ;-) HTH, Jorge.- On Wed, Mar 14, 2012 at 10:55 AM, Jie Tang wrote: hi everyone . Now I want to draw several lines in one frame.And it seems needs more colors except for blue red,black .Where can i found these color name or define some new color ?thank you . -- TANG Jie Email: totang...@gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] where I can find more color names or color definition?
On Mar 14, 2012, at 10:55 AM, Jie Tang wrote: hi everyone . Now I want to draw several lines in one frame.And it seems needs more colors except for blue red,black .Where can i found these color name or define some new color ?thank you . When you have a question, your first thought should be ... what will happen if I type : ?colors -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Moore-Penrose Generalized determinant?
On 14-03-2012, at 12:41, Sean O'Riordain wrote: Is there a function in R to calculate the generalized determinant of a singular matrix? - similar to the ginv() used to compute the generalized inverse. I can't seem to find any R related posts at all. Is this what you want: http://en.wikipedia.org/wiki/Pseudo-determinant Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Moore-Penrose Generalized determinant?
Since the OP says Generalized determinant (I do not really know what that means), it is different from the usual determinant perhaps? Is it the product of the nonzero eigenvalues? Ranjan On Wed, 14 Mar 2012 10:52:14 -0400 jlu...@ria.buffalo.edu wrote: If the matrix is singular, the determinant of the matrix and its M-P inverse are both zero. Sean O'Riordain sean...@acm.org Sent by: r-help-boun...@r-project.org 03/14/2012 07:41 AM To r-help@r-project.org cc Subject [R] Moore-Penrose Generalized determinant? Is there a function in R to calculate the generalized determinant of a singular matrix? - similar to the ginv() used to compute the generalized inverse. I can't seem to find any R related posts at all. Thanks in advance, Sean O'Riordain Trinity College Dublin -- View this message in context: http://r.789695.n4.nabble.com/Moore-Penrose-Generalized-determinant-tp4471629p4471629.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Questing on fitting Baseline category Logit model
Not sure why VGAM::vglm doesn't work here, but most likely it is the small zero counts cited on the page you quote below. This data set is very sparse. You should communicate with the author of VGAM. You can fit this model with nnet::multinom instead, something like library(nnet) # multinomial logit model (mod1 - multinom(food ~ lake+size+sex, data=Alligator, weights=count)) multinom(food ~ lake+size+sex, data=Alligator, weights=count) # weights: 35 (24 variable) initial value 352.466903 iter 10 value 270.397070 iter 20 value 268.958046 final value 268.932740 converged Call: multinom(formula = food ~ lake + size + sex, data = Alligator, weights = count) Coefficients: (Intercept) lakeHancock lakeOklawaha lakeTrafford sizesmall sexmale fish 1.70178892 -0.57524030.5503569 -1.23679067 0.7303298 0.60639521 invert 0.53452560 -2.35574511.4635491 -0.08096449 2.0665999 0.14342792 other -0.01957203 0.19139190.5764707 0.32102428 1.0209285 0.35382356 reptile -1.15700455 0.55392633.0803954 1.82403973 0.1733300 -0.02116283 Residual Deviance: 537.8655 AIC: 585.8655 On 3/14/2012 4:15 AM, Christofer Bogaso wrote: Dear all, I am facing some problem with how to fit a Baseline category Logit model with R. Basically I am considering famous Alligator data as discussed by Agresti. This data can also be found here: https://onlinecourses.science.psu.edu/stat504/node/174 (there is also an accompanying R file, however the underlying R code could not load the data properly!!!) Below are the stuffs what I have done so far: My_Data- structure(list(Number = c(7L, 4L, 1L, 0L, 0L, 0L, 0L, 1L, 5L, 2L, 16L, 3L, 3L, 0L, 2L, 1L, 2L, 2L, 3L, 3L, 2L, 13L, 2L, 7L, 0L, 6L, 0L, 0L, 1L, 0L, 3L, 0L, 9L, 1L, 1L, 0L, 0L, 1L, 2L, 0L, 3L, 8L, 7L, 6L, 1L, 6L, 0L, 3L, 1L, 5L, 2L, 0L, 4L, 1L, 1L, 0L, 1L, 0L, 4L, 0L, 13L, 9L, 10L, 0L, 0L, 0L, 2L, 1L, 2L, 2L, 3L, 8L, 9L, 1L, 1L, 0L, 0L, 0L, 1L, 1L), Food = structure(c(2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L, 2L, 3L, 5L, 1L, 4L), .Label = c(Bird, Fish, Invertebrate, Other, Reptile), class = factor), Size = structure(c(2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L), .Label = c(Large, Small), class = factor), Sex = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(Female, Male), class = factor), Lake = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(George, Hancock, Oklawaha, Trafford), class = factor)), .Names = c(Number, Food, Size, Sex, Lake), row.names = c(NA, 80L), class = data.frame) library(VGAM) vglm(Food~Size+Sex+Lake, data = My_Data, fam=multinomial, weights = Number) However I am getting following error: Error in if (max(abs(ycounts - round(ycounts))) smallno) warning(converting 'ycounts' to integer in @loglikelihood) : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 2: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 3: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 4: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 5: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 6: In checkwz(wz, M = M, trace = trace, wzepsilon = control$wzepsilon) : 96 elements replaced by 1.819e-12 Can somebody points me why I am getting this error? Thanks for you help -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca
Re: [R] How to use a saved SVM model from e1071
Hi Thomas, On Wed, Mar 14, 2012 at 11:00 AM, Thomas Coffin thomas.cof...@artelys.com wrote: Hello, I have an SVM model previously calibrated using libsvm R implementation from the e1071 package. I would like to use this SVM to predict values, from a Java program. I first tried to use jlibsvm and the standard java implementation of libsvm, without success. Thus, I am now considering writing data in files from my Java code, calling an R program to predict values, then gather the predicted values in Java. The problem is that I do not know how to re-use the model saved using the write.svm() function, since there is no read.svm() function. I read the following message in the mailing archive, stating that I may use the save and load methods built in R : http://www.mail-archive.com/r-help@r-project.org/msg64428.html Still, I am not sure how to pre-process the data and to post-process the results. Since write.svm() writes .scale and .ysale files as well as an svm file, I figure that the scaling data is included in the svm object. Does that mean that I do not have to worry about scaling my data and unscaling the results provided by the predict function on a model reloaded using save/load ? I am asking this because I previously succeeded in loading the svm model from libsvm in Java, but the results using unscaled data were obviously wrong. I think you'll find it helpful (and enlightening) to peruse the source code of the svm stuffs in e1071. Start with the `svm.default` function: you'll see where the scale attributes are calculated (and stored) in the returned object. Then take a peak at the `predict.svm` function. You'll find if and when any scaling is performed on the `newdata` object you are trying to predict labels on. In short, things should just work if you save/load the svm object you've previously learned as long as your `newdata` object maintains the same structure your training data had (number and type of features (and column names if you're using the formula interface, I guess)). HTH, -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] logical test not functioning correctly on zoo series...what the hell?
On Mar 14, 2012, at 7:57 AM, knavero wrote: Here's the raw data I'm working with (will be available temporarily): http://dl.dropbox.com/u/41922443/dataout_2471_843.csv Nothing appears. Next, here's the code I want to impose (error that I'm seeing SHOULD reproduce on your shell when script is executed...btw using Ubuntu Linux 11.10 if that makes a difference): http://pastebin.com/LDNw8UT0 The issue specifically is the last line of code in which I want to print out any value greater than 0. You're missing a comma between 0 and ] in the last line if your goal is to retrieve the rows that satisfy that condition (and if the condition makes any sense). Haven't tested the rest of your code, though. ?Extract The outputs that I'm getting, however, are printing out 0's down the columns. I've tried various methods assuming various theories, read the R manual via ? for different possible solutions, Googled stuff, tried the ifelse function which produces the same error, tried creating logical vectors to get a better visual of what the process is, tried doing all of the above on a small sample data set (which actually works correctly for some reason, but doesn't work on the actual raw data), and basically have done a lot of research and trial and error before posting on here. Help is much appreciated. Thank you. P.S. I hope I asked this correctly on the forum (putting reproducible code that reproduces the error, etc.). If there is an error then you should post the complete error message. If I made some noob mistake, I apologize in advance so please don't be mad at me. I will clarify if necessary. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to test the statistical significance of the difference of two univariate Linear Regression betas?
How to test the statistical significance of the difference of two univariate Linear Regression betas? Hi all, There are two samples of data: D1 and D2. On data D1 we do a univariate Linear Regression and get the coefficient beta1. On data D2 we do a univariate Linear Regression and get the coefficient beta2. How do I test the statistical significance of (beta1-beta2)? Could you please recommend packages/commands in R for doing this? Thanks a lot! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] where I can find more color names or color definition?
Here's a function I stole from a blog post somewhere (I forgot where and I'm pressed for time, but I'm sure google can recover it) -- it might be helpful to you: `col.wheel` - function(str, nearby=3, cex=0.75) { cols - colors() hsvs - rgb2hsv(col2rgb(cols)) srt - order(hsvs[1,], hsvs[2,], hsvs[3,]) cols - cols[srt] ind - grep(str, cols) if (length(ind) 1) stop(no colour matches found, call.=FALSE) #s.ind - ind #if (nearby1) for (i in 1:nearby) { # s.ind - c(s.ind, ind+i, ind-i) #} ind - sort(unique(as.vector(outer(ind, -nearby:nearby, + ind - ind[ind = length(cols)] cols - cols[ind] pie(rep(1, length(cols)), labels=cols, col=cols, cex=cex) cols } Behold, a good use of the bad ink/info ratio of a pie chart! Michael On Wed, Mar 14, 2012 at 11:06 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: apropos(color) ?colors colors() Michael On Wed, Mar 14, 2012 at 10:55 AM, Jie Tang totang...@gmail.com wrote: hi everyone . Now I want to draw several lines in one frame.And it seems needs more colors except for blue red,black .Where can i found these color name or define some new color ?thank you . -- TANG Jie Email: totang...@gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to use ggplot to do the binned quantile plots(one type of scatter plot)?
How to use ggplot to do the binned quantile plots(one type of scatter plot)? Hi all, I have done scatter plot: plot(x, y). Now I wanted to do binned quantile plots... can ggplot2 help me? For example, we bin x data into 10 bins. For each bin, we draw the 10 deciles of the corresponding y data in that bin as points/dots. And then accross all bins, we would like to connect the corresponding decile points/dots together(something like equi-quantile or equi-decile curves)... How do I do that in R or ggplot2? Is there an existing function/command that can do this? Thanks a lot! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] extract values for the dates and a new column
#add column Start Hello Good Afternoon I am trying to create a new column in the data frame, the target is based on a column of dates to extract a value of life and add a new column to data frame f-x.res$T-x.res$duration Dataset$StarEvent-(as.character.POSIXt(f)) x.sub$T is: [1] 2006-10-31 20:10:35 EST 2006-10-31 20:11:08 EST 2006-10-31 20:11:21 EST [4] 2006-10-31 20:12:16 EST 2006-10-31 20:13:20 EST 2006-10-31 20:13:28 EST x$duration 159 234 345 35 544 Error in `$-.data.frame`(`*tmp*`, StarEvent, value = c(2006-10-31 20:08:03, : replacement has 18 rows, data has 103) -- View this message in context: http://r.789695.n4.nabble.com/extract-values-for-the-dates-and-a-new-column-tp4472052p4472052.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshaping a dataset for a network
I see you have a solution, but why do you want the results of split() in matrix form? E.g., does it make a nicer printout, is it needed to interface with other R functions, is it needed to interface with other software? Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: Marco Guerzoni [mailto:marco.guerz...@unito.it] Sent: Wednesday, March 14, 2012 1:02 AM To: William Dunlap Cc: r-help@r-project.org Subject: Re: [R] reshaping a dataset for a network Thank you fro the reply. I managed to arrive till here, then I would like to have it in matrix where the $1 $2...$5 are the first column. Il 3/13/2012 8:15 PM, William Dunlap ha scritto: Is the following what you want? a- c(1,2,3,4,4,4,5,5) b- c(11,7,4,9,8,3,12,4) split(b, a) $1 [1] 11 $2 [1] 7 $3 [1] 4 $4 [1] 9 8 3 $5 [1] 12 4 Here I did c - split(b, a) d - do.call(rbind,c) and I get [,1] [,2] [,3] 1 11 11 11 2777 3444 4983 5 124 12 Instead of what I would like: [,1] [,2] [,3] 1 11 27 34 4983 5 124 A solution could be rbind.fill , which does not seem to work with list. thanks Marco Guerzoni, Department of Economics University of Turin Note that your df-cbind(a,b) produces a matrix, not the data.frame that your df suggests you want. Use df-data.frame(a,b) to make a data.frame. Then you could do with(df, split(a,b)) to operate on the a and b in the data.frame df. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Marco Guerzoni Sent: Tuesday, March 13, 2012 10:51 AM To: r-help@r-project.org Subject: [R] reshaping a dataset for a network dear all, apologizes for bothering with a probably stupid question but I really don' t know how to proceed. I have a dataset which look like df a- c(1,2,3,4,4,4,5,5) b- c(11,7,4,9,8,3,12,4) df-cbind(a,b) I would like to have one which looks like this: a 1 11 2 7 3 4 4 9 8 3 5 12 4 a are vertex of a network, b the edges. In the data the lenght of a is about 5 I read several posts about reshape, reshape2, split, ldply but I couldn't manage to do it. The problem seems to be that the is not a real panel. Any help would be really appreciated, my best regards Marco __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use ggplot to do the binned quantile plots(one type of scatter plot)?
On Mar 14, 2012, at 11:33 AM, Michael wrote: How to use ggplot to do the binned quantile plots(one type of scatter plot)? More like a quantile regression plot. Hi all, I have done scatter plot: plot(x, y). Now I wanted to do binned quantile plots... can ggplot2 help me? For example, we bin x data into 10 bins. For each bin, we draw the 10 deciles of the corresponding y data in that bin as points/dots. And then accross all bins, we would like to connect the corresponding decile points/dots together(something like equi-quantile or equi- decile curves)... How do I do that in R or ggplot2? Is there an existing function/ command that can do this? I'm not aware of it if there is. But I agree that it can be a very informative display of data. I do such plots on data structures generated using tapply with age, sex categories and quantile() to generate a value. It gets kind of hairy with the list structure that results but if you have a more simple data situation it will probably be more straightforward, and you should post it. [[alternative HTML version deleted]] And you should learn to post in plain text PLEASE do read the posting guide http://www.R-project.org/posting-guide.html And you should read the Posting Guide. and provide commented, minimal, self-contained, reproducible code. And I already said that. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with expression
On Wed, Mar 14, 2012 at 8:56 AM, Thomas Hoffmann hoffm...@giub.uni-bonn.de wrote: Hi all, I still fail to plot an axis title with the following expression: plot(0,xlab=expression('(SOC [' * kgm^{-2} * '])' * ^{-2})) the xlab should look like: (SOC [kgm^2])^0.25 with an out bracket and a superscript. Like this ? plot(0,xlab=expression(paste('(SOC[',kgm^-2,'])'^0.25,sep=''))) Thanks for your advice. Thomas [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Real-Time data transfer from Excel to R
Yes. please look at RExcel. You can download it from rcom.univie.ac.at The wiki page there has many papers discussing similar projects (follow the Literature link in the left column). Followup should be on the rcom mailing list. Rich On Wed, Mar 14, 2012 at 7:12 AM, burcy dupuy.dang...@free.fr wrote: Hi All I receive through DDE ,real time data from an external supplier on an Excel 2003 sheet. I use R as platform to make backtest trading and prepare trade. My question : Is existing a solution to transfer real-time data from Excel to R? Such transfer keeping the streaming condition. I don't intend to open an account to IB. And I don't want make backtest on Excel,using R as calculator Thanks for help Burcy -- View this message in context: http://r.789695.n4.nabble.com/Real-Time-data-transfer-from-Excel-to-R-tp4471569p4471569.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] logical test not functioning correctly on zoo series...what the hell?
The outputs that I'm getting, however, are printing out 0's down the columns. I've tried various methods assuming various theories, read the R manual via ? for different possible solutions, Googled stuff, tried the ifelse function which produces the same error, tried creating logical vectors to get a better visual of what the process is, tried doing all of the above on a small sample data set (which actually works correctly for some reason, but doesn't work on the actual raw data), and basically have done a lot of research and trial and error before posting on here. Help is much appreciated. Thank you. P.S. I hope I asked this correctly on the forum (putting reproducible code that reproduces the error, etc.). ... [show rest of quote] If there is an error then you should post the complete error message. Hm, technically there is no error message? It just prints zeros (the wrong output) as a result of explicitly making the logical condition 0. But anyway, I'll be sure to copy paste the error output next time. Thanks for the advice. -- View this message in context: http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4472236.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use ggplot to do the binned quantile plots(one type of scatter plot)?
?quantile on the individual bins, make your deciles, then plot the ten series as usual with your x values at the midpoint of the bins. Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360) 407-7534 Olympia, WA 98504-7600 USPS: PO Box 47600, Olympia, WA 98504-7600 Parcels:300 Desmond Drive, Lacey, WA 98503-1274 On Wed, 14 Mar 2012, David Winsemius wrote: On Mar 14, 2012, at 11:33 AM, Michael wrote: How to use ggplot to do the binned quantile plots(one type of scatter plot)? More like a quantile regression plot. Hi all, I have done scatter plot: plot(x, y). Now I wanted to do binned quantile plots... can ggplot2 help me? For example, we bin x data into 10 bins. For each bin, we draw the 10 deciles of the corresponding y data in that bin as points/dots. And then accross all bins, we would like to connect the corresponding decile points/dots together(something like equi-quantile or equi-decile curves)... How do I do that in R or ggplot2? Is there an existing function/command that can do this? I'm not aware of it if there is. But I agree that it can be a very informative display of data. I do such plots on data structures generated using tapply with age, sex categories and quantile() to generate a value. It gets kind of hairy with the list structure that results but if you have a more simple data situation it will probably be more straightforward, and you should post it. [[alternative HTML version deleted]] And you should learn to post in plain text PLEASE do read the posting guide http://www.R-project.org/posting-guide.html And you should read the Posting Guide. and provide commented, minimal, self-contained, reproducible code. And I already said that. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] extract values for the dates and a new column
The error seems clear enough to me... you are trying to mix vectors of different lengths where one length is not a multiple of the other length. Your discussion is pretty confused though, referring to possible data frames x, x.sub, x.res and Dataset. You might benefit from reviewing ?str and ?dput for future posts. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. RMSOPS ricardosousa2...@clix.pt wrote: #add column Start Hello Good Afternoon I am trying to create a new column in the data frame, the target is based on a column of dates to extract a value of life and add a new column to data frame f-x.res$T-x.res$duration Dataset$StarEvent-(as.character.POSIXt(f)) x.sub$T is: [1] 2006-10-31 20:10:35 EST 2006-10-31 20:11:08 EST 2006-10-31 20:11:21 EST [4] 2006-10-31 20:12:16 EST 2006-10-31 20:13:20 EST 2006-10-31 20:13:28 EST x$duration 159 234 345 35 544 Error in `$-.data.frame`(`*tmp*`, StarEvent, value = c(2006-10-31 20:08:03, : replacement has 18 rows, data has 103) -- View this message in context: http://r.789695.n4.nabble.com/extract-values-for-the-dates-and-a-new-column-tp4472052p4472052.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] logical test not functioning correctly on zoo series...what the hell?
Here's the raw data I'm working with (will be available temporarily): http://dl.dropbox.com/u/41922443/dataout_2471_843.csv Nothing appears. ^ Clicking on the link should prompt you to download a csv file and save it somewhere in your HDD. -- View this message in context: http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4472215.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MANOVA and Extra Sums-of-Squares Tests
Hi John, Thanks again. That looks like an easy and convenient approach. Regards, Chris -- View this message in context: http://r.789695.n4.nabble.com/MANOVA-and-Extra-Sums-of-Squares-Tests-tp4470077p4472265.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with expression
On Mar 14, 2012, at 11:53 AM, ilai wrote: On Wed, Mar 14, 2012 at 8:56 AM, Thomas Hoffmann hoffm...@giub.uni-bonn.de wrote: Hi all, I still fail to plot an axis title with the following expression: plot(0,xlab=expression('(SOC [' * kgm^{-2} * '])' * ^{-2})) the xlab should look like: (SOC [kgm^2])^0.25 with an out bracket and a superscript. Like this ? plot(0,xlab=expression(paste('(SOC[',kgm^-2,'])'^0.25,sep=''))) If so, then this is more simple: plot(0,xlab=expression('(SOC['*kgm^-2*'])'^0.25)) # using * as a spaceless connector And as far as I know, unlike the base R paste function, there is no sep argument in the plotmath paste function. Look what happens with: plot(0,xlab=expression(paste('(SOC[',kgm^-2,'])'^0.25,sep='#'))) # not used as a separator above, but rather is appended at end And: plot(0,xlab=expression(paste('(SOC[',kgm^-2,'])'^0.25))) # no default space -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] logical test not functioning correctly on zoo series...what the hell?
On Mar 14, 2012, at 11:47 AM, knavero wrote: Here's the raw data I'm working with (will be available temporarily): http://dl.dropbox.com/u/41922443/dataout_2471_843.csv Nothing appears. ^ Clicking on the link should prompt you to download a csv file and save it somewhere in your HDD. Nope. I just see a blank screen. pastedGraphic.pdf Description: Adobe PDF document -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Amount of memory occupied by data type
Thanks David for the details and pointer to bitops functions. Buried a bit deep that was. I like to think the memory constraints of win xp keeps my code lean and efficient. RAM is like a suburban garage, the bigger it is, the more useless junk people stuff in there. Michael Folkes -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: March 13, 2012 5:25 PM To: Folkes, Michael Cc: r-help@r-project.org Subject: Re: [R] Amount of memory occupied by data type On Mar 13, 2012, at 7:02 PM, Folkes, Michael wrote: Hello all, I was under the (false?) assumption that an object that is class logical, would take up less memory than an object with class integer. Nope. Below am I correctly showing this is not the case? This was an attempt to reduce memory usage. I think there is a package that will do bitwise operations. Yep... all we needed to do is look: http://finzi.psych.upenn.edu/R/library/bitops/html/00Index.html I'm dealing with two large arrays (could be integers). Their contents are the exact same, but one has NA's in random locations. I thought instead of having the second array as an integer, it could be logical and the TRUE vs FALSE could be used to update data in the first array. (but even this idea may be weak if I just end up with a third temporary array...) You probably would since any assignment is going to create a copy. And even having a bitwise logical option wouldn't necessarily help since the indexing would be of necessity either integer or logical (both 8 bit values). I'm running win xp sp3, R version 2.14.1 (2011-12-22). 31-bit addressing constraints as well? (That's so last decade.) You aren't making life easy for yourself are you. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to test the statistical significance of the difference of two univariate Linear Regression betas?
Hi: I'm jot sure if it's exactly what you want but check out Hotelling's paper from 1940. It should be in the archives because I answered this question before ( not from you ). If you can't find it, I'll find the title actually, here's the title: Hotelling, The Selection of Variates For Use in Prediction with Some Comments on the General Problem of Nuisance Parameters, Annals of Mathematical Statistics, 11, 271-283. On Wed, Mar 14, 2012 at 11:21 AM, Michael comtech@gmail.com wrote: How to test the statistical significance of the difference of two univariate Linear Regression betas? Hi all, There are two samples of data: D1 and D2. On data D1 we do a univariate Linear Regression and get the coefficient beta1. On data D2 we do a univariate Linear Regression and get the coefficient beta2. How do I test the statistical significance of (beta1-beta2)? Could you please recommend packages/commands in R for doing this? Thanks a lot! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gam - Y axis probability scale with confidence/error lines
The predict() function has an option 'se.fit' that returns what you are asking for. If you set this equal to TRUE in your code: pred - predict(fit,data.frame(x=xx),type=response,se.fit=TRUE) will return a list with two elements, 'fit' and 'se.fit'. The pointwise confidence intervals will then be pred$fit + 1.96*se.fit pred$fit - 1.96*se.fit for 95% confidence intervals (replace 1.96 with the appropriate quantile of the normal distribution for other confidence levels). You can then do whatever stuff you want to do with them, including plot them. --Patrick On 03/14/2012 10:48 AM, Ben quant wrote: Hello, How do I plot a gam fit object on probability (Y axis) vs raw values (X axis) axis and include the confidence plot lines? Details... I'm using the gam function like this: l_yx[,2] = log(l_yx[,2] + .0004) fit- gam(y~s(x),data=as.data.frame(l_yx),family=binomial) And I want to plot it so that probability is on the Y axis and values are on the X axis (i.e. I don't want log likelihood on the Y axis or the log of my values on my X axis): xx- seq(min(l_yx[,2]),max(l_yx[,2]),len=101) plot(xx,predict(fit,data.frame(x=xx),type=response),type=l,xaxt=n,xlab=Churn,ylab=P(Top Performer)) at- c(.001,.01,.1,1,10) #-- I'd also like to generalize this rather than hard code the numbers axis(1,at=log(at+ .0004),label=at) So far, using the code above, everything looks the way I want. But that does not give me anything information on variability/confidence/certainty. How do I get the dash plots from this: plot(fit) ...on the same scales as above? Related question: how do get the dashed values out of the fit object so I can do 'stuff' with it? Thanks, Ben PS - thank you Patrick for your help previously. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Patrick Breheny Assistant Professor Department of Biostatistics Department of Statistics University of Kentucky __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] logical test not functioning correctly on zoo series...what the hell?
You're missing a comma between 0 and ] in the last line if your goal is to retrieve the rows that satisfy that condition (and if the condition makes any sense). Haven't tested the rest of your code, though. ?Extract The outputs that I'm getting, however, are printing out 0's down the columns. I've tried various methods assuming various theories, read the R manual via ? for different possible solutions, Googled stuff, tried the ifelse function which produces the same error, tried creating logical vectors to get a better visual of what the process is, tried doing all of the above on a small sample data set (which actually works correctly for some reason, but doesn't work on the actual raw data), and basically have done a lot of research and trial and error before posting on here. Help is much appreciated. Thank you. P.S. I hope I asked this correctly on the forum (putting reproducible code that reproduces the error, etc.). ... [show rest of quote] If there is an error then you should post the complete error message. About to post the error because it's still showing up. I understand the , is supposed to act as an (x, y) or (i, j) separator such that [,1] would be column 1 similar to how rawData$KW.ch..1..set.0. looks at the same column. Let me know if you're able to retrieve the csv file from the dropbox link. Again, it should prompt you to download it. I would've put a smaller sample size, but the logical condition seemed to work on a small scale version unfortunately, thus being unable to reproduce the problem. -- View this message in context: http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4472301.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshaping a dataset for a network
Il 3/14/2012 4:43 PM, William Dunlap ha scritto: I see you have a solution, but why do you want the results of split() in matrix form? E.g., does it make a nicer printout, is it needed to interface with other R functions, is it needed to interface with other I need matrix to export the data in to pajek. I don't any other way to have them like this and save them as text file. Probably is my lack of knowledge... software? Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: Marco Guerzoni [mailto:marco.guerz...@unito.it] Sent: Wednesday, March 14, 2012 1:02 AM To: William Dunlap Cc: r-help@r-project.org Subject: Re: [R] reshaping a dataset for a network Thank you fro the reply. I managed to arrive till here, then I would like to have it in matrix where the $1 $2...$5 are the first column. Il 3/13/2012 8:15 PM, William Dunlap ha scritto: Is the following what you want? a- c(1,2,3,4,4,4,5,5) b- c(11,7,4,9,8,3,12,4) split(b, a) $1 [1] 11 $2 [1] 7 $3 [1] 4 $4 [1] 9 8 3 $5 [1] 12 4 Here I did c- split(b, a) d- do.call(rbind,c) and I get [,1] [,2] [,3] 1 11 11 11 2777 3444 4983 5 124 12 Instead of what I would like: [,1] [,2] [,3] 1 11 27 34 4983 5 124 A solution could be rbind.fill , which does not seem to work with list. thanks Marco Guerzoni, Department of Economics University of Turin Note that your df-cbind(a,b) produces a matrix, not the data.frame that your df suggests you want. Use df-data.frame(a,b) to make a data.frame. Then you could do with(df, split(a,b)) to operate on the a and b in the data.frame df. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Marco Guerzoni Sent: Tuesday, March 13, 2012 10:51 AM To: r-help@r-project.org Subject: [R] reshaping a dataset for a network dear all, apologizes for bothering with a probably stupid question but I really don' t know how to proceed. I have a dataset which look like df a- c(1,2,3,4,4,4,5,5) b- c(11,7,4,9,8,3,12,4) df-cbind(a,b) I would like to have one which looks like this: a 1 11 2 7 3 4 4 9 8 3 5 12 4 a are vertex of a network, b the edges. In the data the lenght of a is about 5 I read several posts about reshape, reshape2, split, ldply but I couldn't manage to do it. The problem seems to be that the is not a real panel. Any help would be really appreciated, my best regards Marco __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] logical test not functioning correctly on zoo series...what the hell?
Here's the exact error I'm receiving: http://pastebin.com/mNsPauwk Tracked each output along the way. Starting to think there's a bug in the source code. -- View this message in context: http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4472337.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Reading and analyzing data with two headers
I have data that I would like to analyze in R with the following format: *,M1,,M2, *,S1,S2,S1,S2, p1,m1s1v1,m1s2v1,m2s1v1,m2s2v1 p2,m1s1v2,m1s2v2,m2s1v2,m2s2v2 ..,...,...,..., so I have a method M1 and M2 and each of these have attributes that I would like to analyze for the different problems p1,p2... So I would like to read the table and get some kind of summary like, For method M1 the average on S1 is ... The avererage on S2 is ... and the same thing for method M2. I tried reading using the cvs reading function but it doesn't work the way I want. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] climate data, Netcdf
As you can see: time is from 1 to 1460, 1 means they the measure Tem for the globe at the first 6 hours , 2=after 12 hours .; and so on 1460 *6 = 8760 hours which equals 1 year first of all I want to convert all data from kelvin to degree second I want to convert from 6 hourly to daily and make it like this raw datawhat i want to make time temp (k) 1(6horse)290 2 289 3 4 1 day (min,max,averag) one map(file) for the globe 5 6 7 8 2 second map(file) for the . ; ; ; 1460365 days so in the end will develop 365 file fordaily min Tem 365 file for daily max Tem 365 file for average daily Tem Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/climate-data-Netcdf-tp4472352p4472352.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to test the statistical significance of the difference of two univariate Linear Regression betas?
On Mar 14, 2012, at 16:21 , Michael wrote: How to test the statistical significance of the difference of two univariate Linear Regression betas? Hi all, There are two samples of data: D1 and D2. On data D1 we do a univariate Linear Regression and get the coefficient beta1. On data D2 we do a univariate Linear Regression and get the coefficient beta2. How do I test the statistical significance of (beta1-beta2)? Could you please recommend packages/commands in R for doing this? Well, the large-sample test would be to calculate the se of the difference as se - sqrt(se1^2+se2^2) and then Z - (beta1-beta2)/se; 2*pnorm(-abs(Z)). For small samples you might consider joining the two data sets and test for an interaction between your predictor and an indicator for D1 or D2. Other options are possible, if you know a bit of theory. Thanks a lot! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to test the statistical significance of the difference of two univariate Linear Regression betas?
1. Is this homework? -- we don't do homework. 2. This is not an R question -- posting to stats.stackexchange.com or other statistics websites is usually more appropriate for such non-R statistical questions 3. General approach: Combine all data; model it with both a simpler (fewer parameter, single slope) model and a more complex (separate slopes for different groups of data); test difference in models (e.g. via likelihood ratio which reduces to anova for the normal theory case). 4. Better approach: Ignore 3, because the test has not been pre-planned, suitable power has not been designed in, or the hypothesis is post hoc, etc., so that P values are therefore likely just nonsense with no sensible interpretation. The correct answer is: The slopes _are_ different (entropy is on my side here -- a very powerful ally that one should avoid messing with). The relevant question then becomes: Are they different enough to matter in your context (which if it's homework is -- who cares?) . 5. Perhaps the best approach: Ignore the rantings of a grumpy statistician and consult your local statistical resource for help, which you clearly need more of then can be provided here. Cheers, Bert On Wed, Mar 14, 2012 at 9:24 AM, Mark Leeds marklee...@gmail.com wrote: Hi: I'm jot sure if it's exactly what you want but check out Hotelling's paper from 1940. It should be in the archives because I answered this question before ( not from you ). If you can't find it, I'll find the title actually, here's the title: Hotelling, The Selection of Variates For Use in Prediction with Some Comments on the General Problem of Nuisance Parameters, Annals of Mathematical Statistics, 11, 271-283. On Wed, Mar 14, 2012 at 11:21 AM, Michael comtech@gmail.com wrote: How to test the statistical significance of the difference of two univariate Linear Regression betas? Hi all, There are two samples of data: D1 and D2. On data D1 we do a univariate Linear Regression and get the coefficient beta1. On data D2 we do a univariate Linear Regression and get the coefficient beta2. How do I test the statistical significance of (beta1-beta2)? Could you please recommend packages/commands in R for doing this? Thanks a lot! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to test the statistical significance of the difference of two univariate Linear Regression betas?
Thank you! How large is large sample? What about 50 data points in D1 and another 50 data points in D2? Thanks a lot! On Wed, Mar 14, 2012 at 11:49 AM, peter dalgaard pda...@gmail.com wrote: On Mar 14, 2012, at 16:21 , Michael wrote: How to test the statistical significance of the difference of two univariate Linear Regression betas? Hi all, There are two samples of data: D1 and D2. On data D1 we do a univariate Linear Regression and get the coefficient beta1. On data D2 we do a univariate Linear Regression and get the coefficient beta2. How do I test the statistical significance of (beta1-beta2)? Could you please recommend packages/commands in R for doing this? Well, the large-sample test would be to calculate the se of the difference as se - sqrt(se1^2+se2^2) and then Z - (beta1-beta2)/se; 2*pnorm(-abs(Z)). For small samples you might consider joining the two data sets and test for an interaction between your predictor and an indicator for D1 or D2. Other options are possible, if you know a bit of theory. Thanks a lot! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use ggplot to do the binned quantile plots(one type of scatter plot)?
How to stack these subplots horizontally and vertically together in a nice way? Thank you! On Wed, Mar 14, 2012 at 11:04 AM, Clint Bowman cl...@ecy.wa.gov wrote: ?quantile on the individual bins, make your deciles, then plot the ten series as usual with your x values at the midpoint of the bins. Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360) 407-7534 Olympia, WA 98504-7600 USPS: PO Box 47600, Olympia, WA 98504-7600 Parcels:300 Desmond Drive, Lacey, WA 98503-1274 On Wed, 14 Mar 2012, David Winsemius wrote: On Mar 14, 2012, at 11:33 AM, Michael wrote: How to use ggplot to do the binned quantile plots(one type of scatter plot)? More like a quantile regression plot. Hi all, I have done scatter plot: plot(x, y). Now I wanted to do binned quantile plots... can ggplot2 help me? For example, we bin x data into 10 bins. For each bin, we draw the 10 deciles of the corresponding y data in that bin as points/dots. And then accross all bins, we would like to connect the corresponding decile points/dots together(something like equi-quantile or equi-decile curves)... How do I do that in R or ggplot2? Is there an existing function/command that can do this? I'm not aware of it if there is. But I agree that it can be a very informative display of data. I do such plots on data structures generated using tapply with age, sex categories and quantile() to generate a value. It gets kind of hairy with the list structure that results but if you have a more simple data situation it will probably be more straightforward, and you should post it. [[alternative HTML version deleted]] And you should learn to post in plain text PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.r-project.org/posting-guide.html And you should read the Posting Guide. and provide commented, minimal, self-contained, reproducible code. And I already said that. -- David Winsemius, MD West Hartford, CT __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] statistical contrasts on 3-way interaction
Hi all, I was trying to use glht() from multcomp package to construct a contrast on interaction term in a linear model to do some comparisons. I am little uncertain on how to construct contrasts on a 3-way interaction containing a continuous variable, and hope someone can confirm what I did is correct or wrong: The linear model has a continuous dependent variable âyâ, with treatment factor âTrtâ with value 0 and 1, a factor variable âAâ with value 0 and 1, a continuous variable âxâ.  A simpler model is:  set.seed(10) dat - cbind(y=c(rnorm(10,3),rnorm(10,4),rnorm(10,3.1),rnorm(10,6)), x=runif(40,5,15), expand.grid(A=rep(factor(0:1),each=10),Trt=factor(0:1)))  fit - lm(y ~ x + Trt * A,dat)  My purpose is to test whether treatment effect is significant given each level of factor A, so I used contrasts:  library(multcomp)  K - rbind(c(0,0,1,0,0), c(0,0,1,0,1)) rownames(K) - c('Trt 1-0|A=0','Trt 1-0|A=1') colnames(K) - names(coef(fit)) K       (Intercept) x Trt1 A1 Trt1:A1 Trt 1-0|A=0      0 0   1  0    0 Trt 1-0|A=1      0 0   1  0    1  (glht.fit - summary(glht(fit, linfct = K), test=adjusted(type='none'))) Linear Hypotheses:                 Estimate Std. Error t value Pr(|t|)  Trt 1-0|A=0 == 0 -0.2720    0.3616 -0.752 0.45701  Trt 1-0|A=1 == 0  1.0690    0.3564  2.999 0.00496 **  Now I suspect independent variable âxâ may play a role in the treatment effect at each level of A, so I would like to add in a 3-way interaction between Trt, A and x:  fit - lm(y ~ x * Trt * A,dat)  If my purpose is to test whether treatment is significant at each level of factor A and certain value of covariate âxâ, for example, when x=10, would following code give me what I wanted?  K - rbind(c(0,0,1,0,10,0,0,0), c(0,0,1,0,10,0,1,10)) rownames(K) - c('Trt 1-0|A=0 x=10','Trt 1-0|A=1 x=10') colnames(K) - names(coef(fit)) K          (Intercept) x Trt1 A1 x:Trt1 x:A1 Trt1:A1 x:Trt1:A1 Trt 1-0|A=0 x=10      0 0   1  0   10   0    0     0 Trt 1-0|A=1 x=10      0 0   1  0   10   0    1     10  (glht.fit - summary(glht(fit, linfct = K), test=adjusted(type='none'))) Linear Hypotheses:                      Estimate Std. Error t value Pr(|t|)   Trt 1-0|A=0 x=10 == 0 -0.3526    0.3254 -1.083 0.286731   Trt 1-0|A=1 x=10 == 0  1.4621    0.3328  4.394 0.000115 ***  So the above test was testing whether treatment effect is significant at each level of factor A when x=10, am I correct? Appreciate if someone would confirm this? Thanks John [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gam - Y axis probability scale with confidence/error lines
That was embarrassingly easy. Thanks again Patrick! Just correcting a little typo to his reply. this is probably what he meant: pred = predict(fit,data.frame(x=xx),type=response,se.fit=TRUE) upper = pred$fit + 1.96 * pred$se.fit lower = pred$fit - 1.96 * pred$se.fit # For people who are interested this is how you plot it line by line: plot(xx,pred$fit,type=l,xlab=fd$getFactorName(),ylab=ylab,ylim= c(min(down),max(up))) lines(xx,upper,type=l,lty='dashed') lines(xx,lower,type=l,lty='dashed') In my opinion this is only important if the desired y axis is different than what plot(fit) gives you for a gam fit (i.e fit - gam(...stuff...)) and you want to plot the confidence intervals. thanks again! Ben On Wed, Mar 14, 2012 at 10:39 AM, Patrick Breheny patrick.breh...@uky.eduwrote: The predict() function has an option 'se.fit' that returns what you are asking for. If you set this equal to TRUE in your code: pred - predict(fit,data.frame(x=xx),**type=response,se.fit=TRUE) will return a list with two elements, 'fit' and 'se.fit'. The pointwise confidence intervals will then be pred$fit + 1.96*se.fit pred$fit - 1.96*se.fit for 95% confidence intervals (replace 1.96 with the appropriate quantile of the normal distribution for other confidence levels). You can then do whatever stuff you want to do with them, including plot them. --Patrick On 03/14/2012 10:48 AM, Ben quant wrote: Hello, How do I plot a gam fit object on probability (Y axis) vs raw values (X axis) axis and include the confidence plot lines? Details... I'm using the gam function like this: l_yx[,2] = log(l_yx[,2] + .0004) fit- gam(y~s(x),data=as.data.frame(**l_yx),family=binomial) And I want to plot it so that probability is on the Y axis and values are on the X axis (i.e. I don't want log likelihood on the Y axis or the log of my values on my X axis): xx- seq(min(l_yx[,2]),max(l_yx[,2]**),len=101) plot(xx,predict(fit,data.**frame(x=xx),type=response),** type=l,xaxt=n,xlab=Churn**,ylab=P(Top Performer)) at- c(.001,.01,.1,1,10) #-- I'd also like to generalize this rather than hard code the numbers axis(1,at=log(at+ .0004),label=at) So far, using the code above, everything looks the way I want. But that does not give me anything information on variability/confidence/** certainty. How do I get the dash plots from this: plot(fit) ...on the same scales as above? Related question: how do get the dashed values out of the fit object so I can do 'stuff' with it? Thanks, Ben PS - thank you Patrick for your help previously. [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Patrick Breheny Assistant Professor Department of Biostatistics Department of Statistics University of Kentucky [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gam - Y axis probability scale with confidence/error lines
Actually, I responded a bit too quickly last time, without really reading through your example carefully. You're fitting a logistic regression model and plotting the results on the probability scale. The better way to do what you propose is to obtain the confidence interval on the scale of the linear predictor and then transform to the probability scale, as in: x - seq(0,1,by=.01) y - rbinom(length(x),size=1,p=x) require(gam) fit - gam(y~s(x),family=binomial) pred - predict(fit,se.fit=TRUE) yy - binomial()$linkinv(pred$fit) l - binomial()$linkinv(pred$fit-1.96*pred$se.fit) u - binomial()$linkinv(pred$fit+1.96*pred$se.fit) plot(x,yy,type=l) lines(x,l,lty=2) lines(x,u,lty=2) -- Patrick Breheny Assistant Professor Department of Biostatistics Department of Statistics University of Kentucky On 03/14/2012 01:49 PM, Ben quant wrote: That was embarrassingly easy. Thanks again Patrick! Just correcting a little typo to his reply. this is probably what he meant: pred = predict(fit,data.frame(x=xx),type=response,se.fit=TRUE) upper = pred$fit + 1.96 * pred$se.fit lower = pred$fit - 1.96 * pred$se.fit # For people who are interested this is how you plot it line by line: plot(xx,pred$fit,type=l,xlab=fd$getFactorName(),ylab=ylab,ylim= c(min(down),max(up))) lines(xx,upper,type=l,lty='dashed') lines(xx,lower,type=l,lty='dashed') In my opinion this is only important if the desired y axis is different than what plot(fit) gives you for a gam fit (i.e fit - gam(...stuff...)) and you want to plot the confidence intervals. thanks again! Ben On Wed, Mar 14, 2012 at 10:39 AM, Patrick Breheny patrick.breh...@uky.edu mailto:patrick.breh...@uky.edu wrote: The predict() function has an option 'se.fit' that returns what you are asking for. If you set this equal to TRUE in your code: pred - predict(fit,data.frame(x=xx),__type=response,se.fit=TRUE) will return a list with two elements, 'fit' and 'se.fit'. The pointwise confidence intervals will then be pred$fit + 1.96*se.fit pred$fit - 1.96*se.fit for 95% confidence intervals (replace 1.96 with the appropriate quantile of the normal distribution for other confidence levels). You can then do whatever stuff you want to do with them, including plot them. --Patrick On 03/14/2012 10:48 AM, Ben quant wrote: Hello, How do I plot a gam fit object on probability (Y axis) vs raw values (X axis) axis and include the confidence plot lines? Details... I'm using the gam function like this: l_yx[,2] = log(l_yx[,2] + .0004) fit- gam(y~s(x),data=as.data.frame(__l_yx),family=binomial) And I want to plot it so that probability is on the Y axis and values are on the X axis (i.e. I don't want log likelihood on the Y axis or the log of my values on my X axis): xx- seq(min(l_yx[,2]),max(l_yx[,2]__),len=101) plot(xx,predict(fit,data.__frame(x=xx),type=response),__type=l,xaxt=n,xlab=Churn__,ylab=P(Top Performer)) at- c(.001,.01,.1,1,10) #-- I'd also like to generalize this rather than hard code the numbers axis(1,at=log(at+ .0004),label=at) So far, using the code above, everything looks the way I want. But that does not give me anything information on variability/confidence/__certainty. How do I get the dash plots from this: plot(fit) ...on the same scales as above? Related question: how do get the dashed values out of the fit object so I can do 'stuff' with it? Thanks, Ben PS - thank you Patrick for your help previously. [[alternative HTML version deleted]] R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/__listinfo/r-help https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/__posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sort list
What sort of plot are you using? I'm not really clear on what your data as a whole look like: if you use dput() you can create a representation and we can work from there. In addition to the resources Josh recommended, the following sites can direct you to all sorts of graphical goodies, all of which come with source code (though at the latter site, they are often a little complicated): http://had.co.nz/ggplot2/ http://addictedtor.free.fr/graphiques/ Michael On Wed, Mar 14, 2012 at 10:13 AM, sybil kennelly sybilkenne...@gmail.com wrote: I appreciate the reading Thank you. May i ask one final question. If i have: matrix: var1 var2 var3 cell1 x x x cell2 x x x cell3 x x x cell4 . . . . cell100 and: vector1 - c(cell1, cell5,cell19, cell50, cell70) your_data$mycells - factor(your_data$cells %in% vector1, c(Special, NotSpecial)) So my output will be something like: [25] Special Special Special Special Special Special [31] Special NotSpecial NotSpecial NotSpecial NotSpecial NotSpecial [37] NotSpecial NotSpecial NotSpecial NotSpecial is there a way to plot the data so that my Special cells are plotted on top of my not special cells. The reason is my data may have 1 not special points,and i may have 5 special cells, I find I'm not able to see where they are on my plot because they are being covered by my not special cells :( I have been looking around for order of factors plotted , 'order of levels, order of factor levels, is this on the right track or can it even be done? Syb On Wed, Mar 14, 2012 at 2:04 PM, sybil kennelly sybilkenne...@gmail.comwrote: I appreciate the reading Thank you. May i ask one final question. If i have: matrix: var1 var2 var3 cell1 x x x cell2 x x x cell3 x x x cell4 . . . . cell100 and: vector1 - c(cell1, cell5,cell19, cell50, cell70) your_data$mycells - factor(your_data$cells %in% vector1, c(Special, NotSpecial)) So my output will be something like: [25] Special Special Special Special Special Special [31] Special NotSpecial NotSpecial NotSpecial NotSpecial NotSpecial [37] NotSpecial NotSpecial NotSpecial NotSpecial is there a way to plot the data so that my Special cells are plotted on top of my not special cells. The reason is my data may have 1 not special points,and i may have 5 special cells, I find I'm not able to see where they are on my plot because they are being covered by my not special cells :( I have been looking around for order of factors plotted , 'order of levels, order of factor levels, is this on the right track or can it even be done? Syb On Tue, Mar 13, 2012 at 12:29 PM, Joshua Wiley jwiley.ps...@gmail.comwrote: On Tue, Mar 13, 2012 at 5:15 AM, sybil kennelly sybilkenne...@gmail.com wrote: Thanks Josh. I'm quite new, just wondering re:factor levels? In this example (shamelessly stolen from the internet): schtyp [1] 0 0 1 0 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 0 schtyp.f - factor(schtyp, labels = c(private, public)) schtyp.f [1] private private public private private private public private public [10] private public public public public private private public public [19] public private Levels: private public in my data i have a table: var1 var2 var3 cell1 x x x cell2 x x x cell3 x x x cell4 . . . . cell100 and i have a subset of those cells that are interesting to me as a list of data list1 = [cell1, cell5,cell19, cell50, cell70] is it possible to create (similar to above): schtyp.f - factor(schtyp, labels = c(special, normal)) Sure. Again, probably better to have cells of interest in a vector, not a list a la: list1 - c(cell1, cell5,cell19, cell50, cell70) your_data$mycells - factor(your_data$cells %in% list1, c(Special, NotSpecial)) basically compares the cells to those in your list and returns TRUE/FALSE, which is then converted to a factor, labeled, and stored. If you are just starting, some background reading will help. Here are some suggestions: 1) Go here: http://www.burns-stat.com/pages/tutorials.html and read the tutorials for R -- Beginning (this should not take more than 1 day). 2) Sit down and read: http://cran.r-project.org/doc/manuals/R-intro.pdf through Appendix A (for now you can probably skip the rest of the appendices). That will probably take another entire day or so. 3) Head back to Patrick Burn's website: http://www.burns-stat.com/pages/tutorials.html and read the intermediate guide, The R Inferno (1-3 days depending if you can read for 8 hours straight or not) Cheers, Josh so that when i plot this data, i can color the items in list1 as one color (eg all the special
Re: [R] Merging fully overlapping groups
This code performs the same operation in about 1/10th the time on my machine. Give it a try. look - function(i) { # look for subsets dif - m[, i] - m apply(dif, 2, min) -0.5 } nosubsets - function(df) { # eliminate events that are subsets of other events in terms of attendance m - table(df$B, df$A) nevents - dim(m)[2] found - sapply(seq(nevents), look) diag(found) - FALSE df[df$A %in% dimnames(m)[[2]][rowSums(found)0.5], ] } nosubsets(DF) Jean mdvaan wrote on 03/13/2012 10:56:33 PM: Hi, I have data on individuals (B) who participated in events (A). If ALL participants in an event are a subset of the participants in another event I would like to remove the smaller event and if the participants in one event are exactly similar to the participants in another event I would like to remove one of the events (I don't care which one). The following example does that however it is extremely slow (and the true dataset is very large). What would be a more efficient way to solve the problem? I really appreciate your help. Thanks! DF - data.frame(read.table(textConnection( A B 1209569832 1209551750 120956734 1877451750 1877451733 187746734 1877469833 1926851750 192686734 1926851733 1926865251 516954441 516915480 51693228 596651733 596665251 596668197 59666734 596651750 596669833 7189135523 718965251 718951733 718969833 7189135522 718968197 71896734 779751750 77976734 779769833 78666734 786669833 786651733 859651733 859651750 859665251 86776734 867751750 867751733 893668197 89366734 893665251 893651733 920451750 920469833 92046734 920451733),head=TRUE,stringsAsFactors=FALSE)) data - unique(DF$A) for (m in 1:length(data)) { for (m in 1:length(data)) { tdata - data[-m] q - 0 for (n in 1:length(tdata)) { if (length(which(DF[DF$A == data[m], 2] %in% DF[DF$A == tdata[n], 2] == TRUE)) == length(DF[DF$A == data[m], 2])) { q - q + 1 } } if (q 0) { data - data[-m] m - m - 1 } } } DF - DF[DF$A %in% data,] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rolling regressions with sample extended one period at a time
My apologies: I was thinking of rolling more in the sense of sliding than creeping. I'm not aware of anything suited for that, but it's not hard to roll your own with something like dats - data.frame(x = 1:100, y = rnorm(100)) for(i in 80:100){ lm(y ~ x, data = dats[1:i, ]) } Michael On Wed, Mar 14, 2012 at 10:38 AM, pie' tcpie...@yahoo.it wrote: Hi, I took a look at the documentation concerning rollapply and it doesnt seem to be the command I need. Just to be more clear, on an initial sample of 80 observations I want to perform a probit regression and save the fitted probabilities in a vector. Subsequently another probit is run on the sample 1-81 with relative save of the fitted probabilities. And so again for the sample 1-82, 1-83, 1-84 etc... through the end of the sample. Does rollapply allow me to do this? P. -- View this message in context: http://r.789695.n4.nabble.com/Rolling-regressions-with-sample-extended-one-period-at-a-time-tp4470316p4471995.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.