[R] Sample size calculation proportions with EpiR: Discrepancy to other calculators
Hallo! I have done a sample size calculation for proportions with EpiR. The input is: treatment group rate p=0.65 control group rate p=0.50 significance level 0.95 power 0.80 two-sided ration group 1 and 2: 1.0 I have done this in the following way: library(epiR) epi.studysize(treat = 0.65, control = 0.5, n = NA, sigma = NA, power = 0.80, r = 1, conf.level = 0.95, sided.test = 2, method = proportions) Result: $n [1] 82 PASS 2002 and NQuery give both 170 subjects per group without continuity correction. With continuity correction 183 per group. Looking at http://statpages.org/proppowr.html I get 182 subjects per group (with continuity correction, I admit). What am I doing wrong? Can anybody explain this? Best wishes Karl __ 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 R connects to the internet
Hello I'm unable to get R to connect to the internet at work and I'm guessing its because of our proxy server. Is there any way to change how R connects to the internet? How do I provide it the proxy address? Thank you Ian Confidential: This electronic message and all contents contain information from Syntel, Inc. which may be privileged, confidential or otherwise protected from disclosure. The information is intended to be for the addressee only. If you are not the addressee, any disclosure, copy, distribution or use of the contents of this message is prohibited. If you have received this electronic message in error, please notify the sender immediately and destroy the original message and all copies. __ 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] sciplot question
On May 26, 2009, at 4:37 , Frank E Harrell Jr wrote: Manuel Morales wrote: On Mon, 2009-05-25 at 06:22 -0500, Frank E Harrell Jr wrote: Jarle Bjørgeengen wrote: On May 24, 2009, at 4:42 , Frank E Harrell Jr wrote: Jarle Bjørgeengen wrote: On May 24, 2009, at 3:34 , Frank E Harrell Jr wrote: Jarle Bjørgeengen wrote: Great, thanks Manuel. Just for curiosity, any particular reason you chose standard error , and not confidence interval as the default (the naming of the plotting functions associates closer to the confidence interval ) error indication . - Jarle Bjørgeengen On May 24, 2009, at 3:02 , Manuel Morales wrote: You define your own function for the confidence intervals. The function needs to return the two values representing the upper and lower CI values. So: qt.fun - function(x) qt(p=.975,df=length(x)-1)*sd(x)/ sqrt(length(x)) my.ci - function(x) c(mean(x)-qt.fun(x), mean(x)+qt.fun(x)) Minor improvement: mean(x) + qt.fun(x)*c(-1,1) but in general confidence limits should be asymmetric (a la bootstrap). Thanks, if the date is normally distributed , symmetric confidence interval should be ok , right ? Yes; I do see a normal distribution about once every 10 years. Is it not true that the students-T (qt(... and so on) confidence intervals is quite robust against non-normality too ? A teacher told me that, the students-T symmetric confidence intervals will give a adequate picture of the variability of the data in this particular case. Incorrect. Try running some simulations on highly skewed data. You will find situations where the confidence coverage is not very close of the stated level (e.g., 0.95) and more situations where the overall coverage is 0.95 because one tail area is near 0 and the other is near 0.05. The larger the sample size, the more skewness has to be present to cause this problem. OK - I'm convinced. It turns out that the first change I made to sciplot was to allow for asymmetric error bars. Is there an easy way (i.e., existing package) to bootstrap confidence intervals in R. If so, I'll try to incorporate this as an option in sciplot. library(Hmisc) ?smean.cl.boot H(arrel)misc :-) Thanks for valuable input Frank. This seems to work fine. (slightly more time consuming , but what do we have CPU power for ) library(Hmisc) library(sciplot) my.ci - function(x) c(smean.cl.boot(x)[2],smean.cl.boot(x)[3]) lineplot .CI (V1 ,V2 ,data = d ,col = c (4 ),err .col = c (1 ),err .width = 0.02 ,legend=FALSE,xlab=Timeofday,ylab=IOPS,ci.fun=my.ci,cex=0.5,lwd=0.7) Have I understood you correct in that this is a more accurate way of visualizing variability in any dataset , than the students T confidence intervals, because it does not assume normality ? Can you explain the meaning of B, and how to find a sensible value (if not the default is sufficient) ? Best regards Jarle Bjørgeengen __ 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 R connects to the internet
On Tue, 26 May 2009 12:52:16 +0530 Menezes, Ian ian_mene...@syntelinc.com wrote: MI I'm unable to get R to connect to the internet at work and I'm MI guessing its because of our proxy server. Is there any way to MI change how R connects to the internet? How do I provide it the MI proxy address? You haven't told which operating system you use. For windows there is the option --internet2 for the Rgui.exe that uses the proxy settings of the explorer. hth Stefan __ 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 R connects to the internet
Stefan, Thanks for the response I'm using the GUI version of R in Windows. I usually just click the R icon on my desktop, so Im not sure how I would use the --internet2 option? Ian Menezes -Original Message- From: Stefan Grosse [mailto:singularit...@gmx.net] Sent: Tuesday, May 26, 2009 1:39 PM To: Menezes, Ian Cc: r-help@r-project.org Subject: Re: [R] How R connects to the internet On Tue, 26 May 2009 12:52:16 +0530 Menezes, Ian ian_mene...@syntelinc.com wrote: MI I'm unable to get R to connect to the internet at work and I'm MI guessing its because of our proxy server. Is there any way to MI change how R connects to the internet? How do I provide it the MI proxy address? You haven't told which operating system you use. For windows there is the option --internet2 for the Rgui.exe that uses the proxy settings of the explorer. hth Stefan Confidential: This electronic message and all contents contain information from Syntel, Inc. which may be privileged, confidential or otherwise protected from disclosure. The information is intended to be for the addressee only. If you are not the addressee, any disclosure, copy, distribution or use of the contents of this message is prohibited. If you have received this electronic message in error, please notify the sender immediately and destroy the original message and all copies. Confidential: This electronic message and all contents contain information from Syntel, Inc. which may be privileged, confidential or otherwise protected from disclosure. The information is intended to be for the addressee only. If you are not the addressee, any disclosure, copy, distribution or use of the contents of this message is prohibited. If you have received this electronic message in error, please notify the sender immediately and destroy the original message and all copies. __ 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] Need a faster function to replace missing data
Many thanks to Jim, Bill, and Carl. Using indexes instead of the for loop gave me my answer in minutes instead of hours! Thanks for all of your great suggestions! Aloha, Tim Tim Clark Department of Zoology University of Hawaii --- On Fri, 5/22/09, jim holtman jholt...@gmail.com wrote: From: jim holtman jholt...@gmail.com Subject: Re: [R] Need a faster function to replace missing data To: Tim Clark mudiver1...@yahoo.com Cc: r-help@r-project.org Date: Friday, May 22, 2009, 4:59 PM Here is a modification that should now find the closest: myvscan-data.frame(c(1,NA,1.5),as.POSIXct(c(12:00:00,12:14:00,12:20:00), + format=%H:%M:%S)) # convert to numeric names(myvscan)-c(Latitude,DateTime) myvscan$tn - as.numeric(myvscan$DateTime) # numeric for findInterval mygarmin-data.frame(c(20,30,40),as.POSIXct(c(12:00:00,12:10:00,12:15:00), + format=%H:%M:%S)) names(mygarmin)-c(Latitude,DateTime) mygarmin$tn - as.numeric(mygarmin$DateTime) # use 'findInterval' na.indx - which(is.na(myvscan$Latitude)) # find NAs # create matrix of values to test the range indices - findInterval(myvscan$tn[na.indx],mygarmin$tn) x - cbind(indices, + abs(myvscan$tn[na.indx] - mygarmin$tn[indices]), # lower + abs(myvscan$tn[na.indx] - mygarmin$tn[indices + 1])) #higher # now determine which index is closer closest - x[,1] + (x[,2] x[,3]) # determine the proper index # replace with garmin latitude myvscan$Latitude[na.indx] - mygarmin$Latitude[closest] myvscan Latitude DateTime tn 1 1.0 2009-05-23 12:00:00 124308 2 40.0 2009-05-23 12:14:00 1243080840 3 1.5 2009-05-23 12:20:00 1243081200 On Fri, May 22, 2009 at 7:39 PM, Tim Clark mudiver1...@yahoo.com wrote: Jim, Thanks! I like the way you use indexing instead of the loops. However, the find.Interval function does not give the right result. I have been playing with it and it seems to give the closest number that is less than the one of interest. In this case, the correct replacement should have been 40, not 30, since 12:15 from mygarmin is closer to 12:14 in myvscan than 12:10. Is there a way to get the function to find the closest in value instead of the next smaller value? I was trying to use which.min to get the closet date but can't seem to get it to work right either. Aloha, Tim Tim Clark Department of Zoology University of Hawaii --- On Fri, 5/22/09, jim holtman jholt...@gmail.com wrote: From: jim holtman jholt...@gmail.com Subject: Re: [R] Need a faster function to replace missing data To: Tim Clark mudiver1...@yahoo.com Cc: r-help@r-project.org Date: Friday, May 22, 2009, 7:24 AM I think this does what you want. It uses 'findInterval' to determine where a possible match is: myvscan-data.frame(c(1,NA,1.5),as.POSIXct(c(12:00:00,12:14:00,12:20:00), format=%H:%M:%S)) # convert to numeric names(myvscan)-c(Latitude,DateTime) myvscan$tn - as.numeric(myvscan$DateTime) # numeric for findInterval mygarmin-data.frame(c(20,30,40),as.POSIXct(c(12:00:00,12:10:00,12:15:00), format=%H:%M:%S)) names(mygarmin)-c(Latitude,DateTime) mygarmin$tn - as.numeric(mygarmin$DateTime) # use 'findInterval' na.indx - which(is.na(myvscan$Latitude)) # find NAs # replace with garmin latitude myvscan$Latitude[na.indx] - mygarmin$Latitude[findInterval(myvscan$tn[na.indx], mygarmin$tn)] myvscan Latitude DateTime tn 1 1.0 2009-05-22 12:00:00 1243008000 2 30.0 2009-05-22 12:14:00 1243008840 3 1.5 2009-05-22 12:20:00 1243009200 On Fri, May 22, 2009 at 12:45 AM, Tim Clark mudiver1...@yahoo.com wrote: Dear List, I need some help in coming up with a function that will take two data sets, determine if a value is missing in one, find a value in the second that was taken at about the same time, and substitute the second value in for where the first should have been. My problem is from a fish tracking study. We put acoustic tags in fish and track them for several days. Location data is supposed to be automatically recorded every time we detect a ping from the fish. Unfortunately the GPS had some problems and sometimes the fishes depth was recorded but not its location. I fortunately had a back-up GPS that was taking location data every five minutes. I would like to merge the two files, replacing the missing value in the vscan (automatic) file with the location from the garmin file. Since we were getting vscan records every 1-2 seconds and garmin records every 5 minutes, I need to find the right place in the vscan file to place the garmin record - i.e. the closest in time, but not greater than 5 minutes. I have written a function
Re: [R] Sample size calculation proportions with EpiR: Discrepancy to other calculators
On 5/26/2009 2:53 AM, Karl Knoblick wrote: Hallo! I have done a sample size calculation for proportions with EpiR. The input is: treatment group rate p=0.65 control group rate p=0.50 significance level 0.95 power 0.80 two-sided ration group 1 and 2: 1.0 I have done this in the following way: library(epiR) epi.studysize(treat = 0.65, control = 0.5, n = NA, sigma = NA, power = 0.80, r = 1, conf.level = 0.95, sided.test = 2, method = proportions) Result: $n [1] 82 PASS 2002 and NQuery give both 170 subjects per group without continuity correction. With continuity correction 183 per group. Looking at http://statpages.org/proppowr.html I get 182 subjects per group (with continuity correction, I admit). What am I doing wrong? Can anybody explain this? epi.studysize(treat = .65, control = .50, n = NA, sigma = NA, power = 0.80, r = 1, conf.level = 0.95, sided.test = 2, method = cohort) gives the same sample size as PASS 2002 and NQuery (170 per group). Best wishes Karl __ 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. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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 multiple graphs based on one variable
Dear List, I would like to create several graphs of similar data. I have x and y values for several different individuals (in this case fish). I would like to plot the x and y values for each fish separately. I can do it using a for loop, but I think I should be using apply. Please let me know what I am doing wrong, or if there is a better way to do this. What I have is: #Test data dat-data.frame(c(rep(1:10,4)),c(rep(1:10,4)),c(rep(c(Tony,Mike,Vicky,Fred),each=10))) names(dat)-c(x,y,Name) #Create function to plot x and y myplot-function() plot(dat$x,dat$y) #Apply the function to each of the names par(mfcol=c(2,2)) apply(dat,2,myplot,by=dat$Name) #Does not work - tried various versions I would like separate plots for Tony, Mike, and Vicky. What is the best way to do this? Thank! Tim Tim Clark Department of Zoology University of Hawaii __ 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 multiple graphs based on one variable
On Tue, 26 May 2009 02:34:55 -0700 (PDT) Tim Clark mudiver1...@yahoo.com wrote: TC I would like separate plots for Tony, Mike, and Vicky. What is the TC best way to do this? use the lattice package: library(lattice) xyplot(y~x|Name,data=dat) Mr. Sarkar (the author of the package) has written an excellent book on his package I recommend it. hth Stefan __ 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 needed on R output
peng chen wrote: Hi, R experts: I am trying to generate data output in the following format: rom_array := ( , 01001001011011101100, 1001001011010101, 1101110100000011, 000100100101001001011001, 000101101101101001101001) I have all the necessary data line, however, I am having trouble generating the double quotation marks along with the trailing comma for each line. Hi Peng and others, I assumed that you wanted to generate that (Pascal?) expression and you have a character or binary numeric vector of the six elements. Say that vector is named binaryvector. cat(rom_array := (\n) ends-c(rep(\,\n,5),\)\n) for(i in 1:length(binaryvector)) cat(\,binaryvector[i],ends[i],sep=) should do what you want. However, I have two questions: 1) Why does cat put a newline at the end of a call with a sep argument with a newline in it? It doesn't put the sep argument after the last element of the vector, even though the help page says that it does. 2) The help page reads: sep a character vector of strings to append after each element. but cat clearly uses only the first string of the vector. Am I reading this wrongly? Jim __ 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] moving from Windows to Linux - need help
hi I've used R for many years on windows machines, but have now acquired an Asus eee 1000 linux machine. In order to get the best out of the machine, I used the 'pimpmyeee.sh' script, to get the full KDE desktop. The version of Linux is Xandros, which I believe is a close relative of Debian, but sadly I have only a nodding acquaintance with Linux at present. Naturally I want to have the current version of R on it, and I understand (or possibly misunderstand) that the binary for the Debian flavour of Linux should do the trick. I have tried - 1. using synaptic to add the appropriate (I think) CRAN repository ... but every combination I have tried gives a 404 error 2. downloading from CRAN what I think is a zipped-up version of r-base software, and thewn using the eee's file-manager 'install DEB package' option ... but this returns 'cannot load ... '. I'm a bit stuck ... can anyone help please ? thanks Bob Kinley [[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 R connects to the internet
Menezes, Ian wrote: Stefan, Thanks for the response I'm using the GUI version of R in Windows. I usually just click the R icon on my desktop, so Im not sure how I would use the --internet2 option? You can edit the shortcut (right click and follow the menus), or install R with that option. Duncan Murdoch Ian Menezes -Original Message- From: Stefan Grosse [mailto:singularit...@gmx.net] Sent: Tuesday, May 26, 2009 1:39 PM To: Menezes, Ian Cc: r-help@r-project.org Subject: Re: [R] How R connects to the internet On Tue, 26 May 2009 12:52:16 +0530 Menezes, Ian ian_mene...@syntelinc.com wrote: MI I'm unable to get R to connect to the internet at work and I'm MI guessing its because of our proxy server. Is there any way to MI change how R connects to the internet? How do I provide it the MI proxy address? You haven't told which operating system you use. For windows there is the option --internet2 for the Rgui.exe that uses the proxy settings of the explorer. hth Stefan Confidential: This electronic message and all contents contain information from Syntel, Inc. which may be privileged, confidential or otherwise protected from disclosure. The information is intended to be for the addressee only. If you are not the addressee, any disclosure, copy, distribution or use of the contents of this message is prohibited. If you have received this electronic message in error, please notify the sender immediately and destroy the original message and all copies. Confidential: This electronic message and all contents contain information from Syntel, Inc. which may be privileged, confidential or otherwise protected from disclosure. The information is intended to be for the addressee only. If you are not the addressee, any disclosure, copy, distribution or use of the contents of this message is prohibited. If you have received this electronic message in error, please notify the sender immediately and destroy the original message and all copies. __ 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 needed on R output
A simpler solution: my.string - c(, 01001001011011101100, 1001001011010101, 1101110100000011, 000100100101001001011001, 000101101101101001101001) my.string - paste(my.string, collapse=\,\n\) cat(paste(rom_array := (\n\, my.string, \)\n, sep=)) Which produces: rom_array := ( , 01001001011011101100, 1001001011010101, 1101110100000011, 000100100101001001011001, 000101101101101001101001) Search in the archives for character escaping to understand the syntax. A simple example (notice the gradual additions): aa - 010 cat(aa) # 010 bb - \010 cat(bb) # 010 cc - \010\ cat(cc) # 010 Also read the help for ?paste, and notice the difference between the sep and collapse arguments. Hth, Adrian Linlin Yan wrote: t - c( + , + 01001001011011101100, + 1001001011010101, + 1101110100000011, + 000100100101001001011001, + 000101101101101001101001) { + cat ('rom_array := (\n'); + for (i in 1:length(t)) { + cat('', t[i], '', + ifelse(i == length(t), '', ',\n'), sep='') + }; + cat(')\n'); + } rom_array := ( , 01001001011011101100, 1001001011010101, 1101110100000011, 000100100101001001011001, 000101101101101001101001) On Tue, May 26, 2009 at 12:30 PM, peng chen rogerchan2...@gmail.com wrote: Hi, R experts: I am trying to generate data output in the following format: rom_array := ( , 01001001011011101100, 1001001011010101, 1101110100000011, 000100100101001001011001, 000101101101101001101001) I have all the necessary data line, however, I am having trouble generating the double quotation marks along with the trailing comma for each line. Anyone can help? Thanks. [[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. -- View this message in context: http://www.nabble.com/Help-needed-on-R-output-tp23716736p23720449.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] Converting a list to a data frame or columns at the least
I have a column in which dates and times are specified thus m/d/ HH:MM:SS Alas, some entries do not include the time and therefore are only m/d/ so I used read.csv and specified that the relevant column should be read as is and it remained as a character variable. I then split the value on the space split.dt.time -strsplit(teacher$Date.and.Time.of.Lesson, ) that gives me a list where each item on the list has two elements if the time was specified and only 1 element if the time was not specified. How do I take that list and make all the 1st elements go into one column and all the second elements go into a second column; where there is no time I would like the value to be missing (NA) I tried playing around with do.call(rbind... so I tried the following unsuccessfully do.call(rbind,lapply(teacher$Date.and.Time.of.Lesson, function(i) strsplit(i, )) ) rbind(strsplit (teacher$Date.and.Time.of.Lesson, )) do.call(rbind(data.frame(strsplit (teacher$Date.and.Time.of.Lesson, Farrel Buchinsky [[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] R-windows unsuccessful
To whom it may concern We are currently trying to utilize your software on windows. We have downloaded all necessary packages and followed instructions as to how to perform the model. Thus the installation has worked perfectly, however when trying to run the program an error message appears Converting xls file to csv file... Error in system(cmd, intern = !verbose) : perl not found Error in file.exists(tfn) : invalid 'file' argument. The software works on Mac computers but not on windows. Could we please have some assistance as to how we can run these models on windows successfully. Regards Honours Class 2009 UKZN South Africa [[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] stricter use of xlim in plot.stepfun
Dear R developer, I am not quite sure, if I should post my concern as a wish to r-b...@r-project.org. Thus, as recommended, I first send an email to you. My request is the following: I would appreciate, if it was possible to obtain a plot of a 'stepfun' with a strict interpretation of xlim. What I mean: sf - stepfun(1:4, 1:5) plot(sf, xlim=c(0,10)) does not bound the function to the horizontal area from 0 to 10, but continues drawing outside this interval. Another situation: I want to add a stepfun to an existing plot: plot(c(0, 50), c(0, 10), type = n) lines(sf, xlim = c(0,10)) The left and right ends of the line drawing are chosen quite arbitrary instead of using the exact xlim information. In the code of plot.stepfun it is the variable 'dr' in conjuction with ti - c(xlim[1L] - dr, knF, xlim[2L] + dr) which determine and alter the x-range of the stepfun internally. What do you think of this issue? Best regards, Sebastian Meyer __ 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 under Ubuntu
R-help, I have installed R under Ubuntu and I'm very new to a Linux distribution. To open an empty R session I just type R on the Terminal aplication. But how can I open a saved workspace? At present I just start R and then load (my_workspace) but it must be possible to do it all at onceright? Thanks in advance __ 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] moving from Windows to Linux - need help
Hi Robert, I had the exact same problem on my eeepc 900. I replaced the xandros-like linux in this way: - Download an Ubuntu iso file (I use 8.04, Kubuntu) - Put the .iso file on a usb stick (use unetbootin) - Install the ubuntu version - Install the eeepc specific stuff from http://array.org/ubuntu/ (this is a repository with an eeepc kernel available and other stuff, the site provides a lot of info on how to install the eeepc specific things) Now you have a normal linux distro (ubuntu) and you can use the normal cran repositories (debian) to install R. This worked very well for me, it was quite easy to get ubuntu running. I know that this isn't an exact answer to your question, but I found that re installing linux was the best option. cheers and hth, Paul Robert Kinley wrote: hi I've used R for many years on windows machines, but have now acquired an Asus eee 1000 linux machine. In order to get the best out of the machine, I used the 'pimpmyeee.sh' script, to get the full KDE desktop. The version of Linux is Xandros, which I believe is a close relative of Debian, but sadly I have only a nodding acquaintance with Linux at present. Naturally I want to have the current version of R on it, and I understand (or possibly misunderstand) that the binary for the Debian flavour of Linux should do the trick. I have tried - 1. using synaptic to add the appropriate (I think) CRAN repository ... but every combination I have tried gives a 404 error 2. downloading from CRAN what I think is a zipped-up version of r-base software, and thewn using the eee's file-manager 'install DEB package' option ... but this returns 'cannot load ... '. I'm a bit stuck ... can anyone help please ? thanks Bob Kinley [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ 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] R-windows unsuccessful
Hi, perl not found This says that perl is not installed, you need to install it. In addition, I am not really sure what all necessary pacakges or your software is and what you want to do with R. Please read the posting guide carefully for requirements for postings to the help list. In addition, it seems that you have written this email on behalf of a class. The primary source for questions is your tutor/teacher. I'm not trying to be rude, but this post is not likely to get useful responses from the mailing list. cheers and good luck, Paul Clinton wrote: To whom it may concern We are currently trying to utilize your software on windows. We have downloaded all necessary packages and followed instructions as to how to perform the model. Thus the installation has worked perfectly, however when trying to run the program an error message appears Converting xls file to csv file... Error in system(cmd, intern = !verbose) : perl not found Error in file.exists(tfn) : invalid 'file' argument. The software works on Mac computers but not on windows. Could we please have some assistance as to how we can run these models on windows successfully. Regards Honours Class 2009 UKZN South Africa [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ 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] moving from Windows to Linux - need help
On Tue, May 26, 2009 at 11:02:22AM +0100, Robert Kinley wrote: I've used R for many years on windows machines, but have now acquired an Asus eee 1000 linux machine. In order to get the best out of the machine, I used the 'pimpmyeee.sh' script, to get the full KDE desktop. The version of Linux is Xandros, which I believe is a close relative of Debian, but sadly I have only a nodding acquaintance with Linux at present. I'm not too familiar with Xandros and when I got my eee 1000 I simply wiped the disk and installed Debian using an extrernal CD-drive plus internet connection. I included a special source line for eeepC specific stuff (don't have it here, but can lookup what it was if desired). I am very happy with the result. cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://mips.gsf.de/staff/pagel __ 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] moving from Windows to Linux - need help
Hi Robert, I agree with Robert. It seems the cleanest way of getting R on Linux is to use one of the Linux distros R is packaged for. It may work otherwise, but there _will_ be more fiddling around resolving dependencies manually or semi manually. Best regards. - Jarle Bjørgeengen On May 26, 2009, at 12:56 , Paul Hiemstra wrote: Hi Robert, I had the exact same problem on my eeepc 900. I replaced the xandros- like linux in this way: - Download an Ubuntu iso file (I use 8.04, Kubuntu) - Put the .iso file on a usb stick (use unetbootin) - Install the ubuntu version - Install the eeepc specific stuff from http://array.org/ubuntu/ (this is a repository with an eeepc kernel available and other stuff, the site provides a lot of info on how to install the eeepc specific things) Now you have a normal linux distro (ubuntu) and you can use the normal cran repositories (debian) to install R. This worked very well for me, it was quite easy to get ubuntu running. I know that this isn't an exact answer to your question, but I found that re installing linux was the best option. cheers and hth, Paul Robert Kinley wrote: hi I've used R for many years on windows machines, but have now acquired an Asus eee 1000 linux machine. In order to get the best out of the machine, I used the 'pimpmyeee.sh' script, to get the full KDE desktop. The version of Linux is Xandros, which I believe is a close relative of Debian, but sadly I have only a nodding acquaintance with Linux at present. Naturally I want to have the current version of R on it, and I understand (or possibly misunderstand) that the binary for the Debian flavour of Linux should do the trick. I have tried - 1. using synaptic to add the appropriate (I think) CRAN repository ... but every combination I have tried gives a 404 error 2. downloading from CRAN what I think is a zipped-up version of r-base software, and thewn using the eee's file-manager 'install DEB package' option ... but this returns 'cannot load ... '. I'm a bit stuck ... can anyone help please ? thanks Bob Kinley [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ 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. -- ~~ Best regards .~. Jarle Bjørgeengen /V\ Mob: +47 9155 7978// \\ http://www.uio.no/sok?person=jb /( )\ while(){if(s/^(.*\?)$/42 !/){print $1 $_}}^`~'^ ~~ __ 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] moving from Windows to Linux - need help
On May 26, 2009, at 1:13 , Jarle Bjørgeengen wrote: Hi Robert, I agree with Robert. You meant you agree with Paul, right ? Of course :-) BR Jarle Bjørgeengen __ 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] stricter use of xlim in plot.stepfun
Sebastian Meyer wrote: Dear R developer, I am not quite sure, if I should post my concern as a wish to r-b...@r-project.org. Thus, as recommended, I first send an email to you. My request is the following: I would appreciate, if it was possible to obtain a plot of a 'stepfun' with a strict interpretation of xlim. What I mean: sf - stepfun(1:4, 1:5) plot(sf, xlim=c(0,10)) does not bound the function to the horizontal area from 0 to 10, but continues drawing outside this interval. Another situation: I want to add a stepfun to an existing plot: plot(c(0, 50), c(0, 10), type = n) lines(sf, xlim = c(0,10)) The left and right ends of the line drawing are chosen quite arbitrary instead of using the exact xlim information. In the code of plot.stepfun it is the variable 'dr' in conjuction with ti - c(xlim[1L] - dr, knF, xlim[2L] + dr) which determine and alter the x-range of the stepfun internally. Hi Sebastian, Have a look at par(xaxs=i), which you can pass to the plot function as well. Jim __ 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] Selection and aggregation in one operation?
I have a large data-frame with measurements such as: id i v1 v2 v3 1 1 1.1 1.2 1.3 1 2 1.4 1.5 1.6 1 3 1.5 1.7 1.8 2 1 2.1 2.2 2.3 2 2 2.7 2.5 2.6 2 3 2.4 2.8 2.9 For each unique value of 'id' (which in the real data-set is a combination of three variables) I want to compute the median of v1 within each group ('i' distinguishes measurements within a group), and copy the value of the remaining columns (v2 and v3). Thus, the desired result for this small example is id i v1 v2 v3 1 2 1.4 1.5 1.6 2 3 2.4 2.8 2.9 I have written a (rather clumsy, in my opinion) function to perform this task (see below). Is there a more standard way of achieving this? The function is: agg.column - function(df, key, groups, FUN) { for(i in 1:length(groups)) groups[[i]] - as.factor(groups[[i]]) groups - split(df, interaction(groups, lex.order=TRUE)) ret - data.frame() for(g in groups) { key.fun - FUN(g[[key]]) row.idx - match(key.fun, g[[key]]) ret - rbind(ret, g[row.idx,]) } ret } __ 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] moving from Windows to Linux - need help
And with ubuntu in combination with the Array.org eeepc repository, the installation is a piece of cake (if you follow the instructions on the site). cheers, Paul Jarle Bjørgeengen wrote: On May 26, 2009, at 1:13 , Jarle Bjørgeengen wrote: Hi Robert, I agree with Robert. You meant you agree with Paul, right ? Of course :-) BR Jarle Bjørgeengen -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ 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] R under Ubuntu
I think it is standard practice. If you want R to load a workspace automatically when R is launched, you can add the command in .Rprofile. See ?Startup for more on Initialization at Start of an R Session. Ronggui 2009/5/26 Luis Ridao Cruz lu...@hav.fo: R-help, I have installed R under Ubuntu and I'm very new to a Linux distribution. To open an empty R session I just type R on the Terminal aplication. But how can I open a saved workspace? At present I just start R and then load (my_workspace) but it must be possible to do it all at onceright? Thanks in advance __ 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. -- HUANG Ronggui, Wincent PhD Candidate Dept of Public and Social Administration City University of Hong Kong Home page: http://asrr.r-forge.r-project.org/rghuang.html __ 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] Selection and aggregation in one operation?
If, as in this example, i is always 1, 2, ... and has an odd length in each group then: do.call(rbind, by(DF, DF$id, function(x) x[median(x$i), ])) On Tue, May 26, 2009 at 8:13 AM, Zeljko Vrba zv...@ifi.uio.no wrote: I have a large data-frame with measurements such as: id i v1 v2 v3 1 1 1.1 1.2 1.3 1 2 1.4 1.5 1.6 1 3 1.5 1.7 1.8 2 1 2.1 2.2 2.3 2 2 2.7 2.5 2.6 2 3 2.4 2.8 2.9 For each unique value of 'id' (which in the real data-set is a combination of three variables) I want to compute the median of v1 within each group ('i' distinguishes measurements within a group), and copy the value of the remaining columns (v2 and v3). Thus, the desired result for this small example is id i v1 v2 v3 1 2 1.4 1.5 1.6 2 3 2.4 2.8 2.9 I have written a (rather clumsy, in my opinion) function to perform this task (see below). Is there a more standard way of achieving this? The function is: agg.column - function(df, key, groups, FUN) { for(i in 1:length(groups)) groups[[i]] - as.factor(groups[[i]]) groups - split(df, interaction(groups, lex.order=TRUE)) ret - data.frame() for(g in groups) { key.fun - FUN(g[[key]]) row.idx - match(key.fun, g[[key]]) ret - rbind(ret, g[row.idx,]) } ret } __ 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] sciplot question
Jarle Bjørgeengen wrote: On May 26, 2009, at 4:37 , Frank E Harrell Jr wrote: Manuel Morales wrote: On Mon, 2009-05-25 at 06:22 -0500, Frank E Harrell Jr wrote: Jarle Bjørgeengen wrote: On May 24, 2009, at 4:42 , Frank E Harrell Jr wrote: Jarle Bjørgeengen wrote: On May 24, 2009, at 3:34 , Frank E Harrell Jr wrote: Jarle Bjørgeengen wrote: Great, thanks Manuel. Just for curiosity, any particular reason you chose standard error , and not confidence interval as the default (the naming of the plotting functions associates closer to the confidence interval ) error indication . - Jarle Bjørgeengen On May 24, 2009, at 3:02 , Manuel Morales wrote: You define your own function for the confidence intervals. The function needs to return the two values representing the upper and lower CI values. So: qt.fun - function(x) qt(p=.975,df=length(x)-1)*sd(x)/sqrt(length(x)) my.ci - function(x) c(mean(x)-qt.fun(x), mean(x)+qt.fun(x)) Minor improvement: mean(x) + qt.fun(x)*c(-1,1) but in general confidence limits should be asymmetric (a la bootstrap). Thanks, if the date is normally distributed , symmetric confidence interval should be ok , right ? Yes; I do see a normal distribution about once every 10 years. Is it not true that the students-T (qt(... and so on) confidence intervals is quite robust against non-normality too ? A teacher told me that, the students-T symmetric confidence intervals will give a adequate picture of the variability of the data in this particular case. Incorrect. Try running some simulations on highly skewed data. You will find situations where the confidence coverage is not very close of the stated level (e.g., 0.95) and more situations where the overall coverage is 0.95 because one tail area is near 0 and the other is near 0.05. The larger the sample size, the more skewness has to be present to cause this problem. OK - I'm convinced. It turns out that the first change I made to sciplot was to allow for asymmetric error bars. Is there an easy way (i.e., existing package) to bootstrap confidence intervals in R. If so, I'll try to incorporate this as an option in sciplot. library(Hmisc) ?smean.cl.boot H(arrel)misc :-) Thanks for valuable input Frank. This seems to work fine. (slightly more time consuming , but what do we have CPU power for ) library(Hmisc) library(sciplot) my.ci - function(x) c(smean.cl.boot(x)[2],smean.cl.boot(x)[3]) Don't double the executing time by running it twice! And this way you might possibly get an upper confidence interval that is lower than the lower one. Do function(x) smean.cl.boot(x)[-1] lineplot.CI(V1,V2,data=d,col=c(4),err.col=c(1),err.width=0.02,legend=FALSE,xlab=Timeofday,ylab=IOPS,ci.fun=my.ci,cex=0.5,lwd=0.7) Have I understood you correct in that this is a more accurate way of visualizing variability in any dataset , than the students T confidence intervals, because it does not assume normality ? Yes but instead of saying variability (which quantiles are good at) we are talking about the precision of the mean. Can you explain the meaning of B, and how to find a sensible value (if not the default is sufficient) ? For most purposes the default is sufficient. There are great books and papers on the bootstrap for more info, including improved variations on the simple bootstrap percentile confidence interval used here. Frank Best regards Jarle Bjørgeengen -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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 for arma mdel with constraints on parameters
Hi, i am learning R recently and find it very helpful in time series model. In ARMA model, given (p,q) it can get the estimation of a[i] and b[j] easily with arima() function. X[t] = a[1]X[t-1] + ... + a[p]X[t-p] + e[t] + b[1]e[t-1] + ... + b[q]e[t-q] but in my recent data model, i met a problem. In the ARMA model, p and q are fixed, but there are some constraints in the parameters a[i] and b[j], such as for some i (ip), a[i]=0. my problem is how to get these parameters' estimation for these constrants with arima() function? or i need to write functions to realize it. Best regards, Tongen from Beijing _ [[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] Running R from a read-only CD
On Mon, 2009-05-25 at 17:36 -0400, Charles Annis, P.E. wrote: I'm not sure how not to use chm help, since that's the only way I've ever done things. But why would things work well from a USB Flash Drive and not for a CD when the folders are identical? (The CD was burned from the image on the Flash Drive.) Charles, I don't use Windows routinely, but do have to use it in our teaching computer clusters. There the system is locked down and users don't have write permissions to the library location and updating the help often occurs only with warnings. Then we get the same error you are seeing. We can, however, read chm help for base or stats or what-have-you but not packages we installed or updated during a session. [I know our computer people could configure all this so it worked better, but it took me best part of 5 years to get them to install R; so I'm thankful just for that!] So, is this a permissions issue? - the CD is read-only and the flash drive I presume is read/write? If you alter the folder on the flash drive to be read-only, do you get the same end result? That might explain the different results. G Charles Annis, P.E. charles.an...@statisticalengineering.com phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] Sent: Monday, May 25, 2009 5:23 PM To: charles.an...@statisticalengineering.com Cc: r-help@r-project.org Subject: Re: [R] Running R from a read-only CD On 25/05/2009 5:18 PM, Charles Annis, P.E. wrote: After reading your suggested page, it does appear that the problem is a security feature that I will have to live with since the CDs will be running on borrowed computers. BUT, if the same R-folder is loaded from a USB Flash Drive, rather than a CD, the help files work just fine. So perhaps there is another way. Any other ideas? Don't use CHM help. Duncan Murdoch Charles Annis, P.E. charles.an...@statisticalengineering.com phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] Sent: Monday, May 25, 2009 4:57 PM To: charles.an...@statisticalengineering.com Cc: r-help@r-project.org Subject: Re: [R] Running R from a read-only CD On 25/05/2009 4:40 PM, Charles Annis, P.E. wrote: Dear R-helpers: I created a folder containing R on a read-only CD and use it by having the R-icon, located on the Windows desktop, point to the CD (R-2.8.1\bin\Rgui.exe) for the Target, and to a Windows Desktop folder for Start in. This works nicely EXCEPT that the R help() function cannot display anything, and presents a screen message saying This program cannot display webpage. This is especially frustrating because on the left of what would be the help window is the exhaustive list of all the functions for which R can provide help (but can't display anything). Can anyone provide guidance? Here is the obligatory session information: sessionInfo() R version 2.8.1 (2008-12-22) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] splines tcltk stats graphics grDevices utils datasets methods base other attached packages: [1] mh1823_2.5.4.1 survival_2.35-3RColorBrewer_1.0-2 RODBC_1.2-5 Thanks! This sounds like a Windows security feature, because .CHM is a risky format. There's a page here http://support.microsoft.com/kb/896054 that tells you how to turn it off. Alternatively, you can choose one of the other help formats in R besides CHM help. Duncan Murdoch __ 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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ 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] facet_grid problem: don't understand error message
The following is a plot that used to work (last December, I think with a patched version of ggplot2 from Hadley), but has stopped working with recent updates. Other instances of facet_grid work and the data look normal to me. Since I have no idea what caused the error message, I'm having trouble producing a reproducible example or solving the problem. Has anyone seen this before? Many thanks, Jacob Etches p - qplot(year,prop.excl,data=subset(excl,!is.na(ftf) exclusion %in% c(disab_inc_rec,family_death,fs_ch,ft2_ch,retir_inc_rec)), geom=c(line), colour=Exclusion, ylab=Proportion of persons per exposure year,xlab=Start year of exposure window) p+ facet_grid(ftf + Sex ~ Age) Error in rbind(c(spacer, strip_h, strip_h, strip_h, strip_h, : number of columns of matrices must match (see arg 2) In addition: Warning message: In rbind(list(1, 1, 1, 1, 1, 1), list(0.77705, 1, 1, 1, 1, 0.5450417, : number of columns of result is not a multiple of vector length (arg 1) [[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] stricter use of xlim in plot.stepfun
Jim wrote: Have a look at par(xaxs=i), which you can pass to the plot function as well. Hi everybody, Thank you very much for your suggestion, Jim. I did not think of that graphical parameter xaxs. It would really be a workaround for my first example. Unfortunately, it does not solve the second situation, where I would like to add the step function to an existing plot within a specified region. Internally, 'xlim' will always be expanded by 'dr' (=diff(xlim)) units to the left and to the right. Perhaps one could add an argument to the plot.stepfun function, with which one can specify this 'dr' variable (see the internals of plot.stepfun) ? Best regards, Sebastian __ 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] split strings
Hi everybody, I have a vector of characters and i would like to extract certain parts. My vector is named metr_list: [1] F:/Naval_Live_Oaks/2005/data//BE.tif [2] F:/Naval_Live_Oaks/2005/data//CH.tif [3] F:/Naval_Live_Oaks/2005/data//CRR.tif [4] F:/Naval_Live_Oaks/2005/data//HOME.tif And i would like to extract BE, CH, CRR, and HOME in a different vector named names.id for example. I read the help files for sub and grep and the likes but i have to recognize that i did not understand it. So i've done this (which does the job but extremely clumsy): b - strsplit(metr_list, //) b - unlist(b) d - strsplit(b, \\.) d - unlist(d) names.id - d[c(2, 5, 8, 11)] Can anybody show what would be the proper way to achieve this with some explanations? Thanks, Monica _ Hotmail® goes with you. ial_Mobile1_052009 __ 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] sciplot question
On May 26, 2009, at 3:02 , Frank E Harrell Jr wrote: Jarle Bjørgeengen wrote: On May 26, 2009, at 4:37 , Frank E Harrell Jr wrote: Manuel Morales wrote: On Mon, 2009-05-25 at 06:22 -0500, Frank E Harrell Jr wrote: Jarle Bjørgeengen wrote: On May 24, 2009, at 4:42 , Frank E Harrell Jr wrote: Jarle Bjørgeengen wrote: On May 24, 2009, at 3:34 , Frank E Harrell Jr wrote: Jarle Bjørgeengen wrote: Great, thanks Manuel. Just for curiosity, any particular reason you chose standard error , and not confidence interval as the default (the naming of the plotting functions associates closer to the confidence interval ) error indication . - Jarle Bjørgeengen On May 24, 2009, at 3:02 , Manuel Morales wrote: You define your own function for the confidence intervals. The function needs to return the two values representing the upper and lower CI values. So: qt.fun - function(x) qt(p=.975,df=length(x)-1)*sd(x)/ sqrt(length(x)) my.ci - function(x) c(mean(x)-qt.fun(x), mean(x)+qt.fun(x)) Minor improvement: mean(x) + qt.fun(x)*c(-1,1) but in general confidence limits should be asymmetric (a la bootstrap). Thanks, if the date is normally distributed , symmetric confidence interval should be ok , right ? Yes; I do see a normal distribution about once every 10 years. Is it not true that the students-T (qt(... and so on) confidence intervals is quite robust against non-normality too ? A teacher told me that, the students-T symmetric confidence intervals will give a adequate picture of the variability of the data in this particular case. Incorrect. Try running some simulations on highly skewed data. You will find situations where the confidence coverage is not very close of the stated level (e.g., 0.95) and more situations where the overall coverage is 0.95 because one tail area is near 0 and the other is near 0.05. The larger the sample size, the more skewness has to be present to cause this problem. OK - I'm convinced. It turns out that the first change I made to sciplot was to allow for asymmetric error bars. Is there an easy way (i.e., existing package) to bootstrap confidence intervals in R. If so, I'll try to incorporate this as an option in sciplot. library(Hmisc) ?smean.cl.boot H(arrel)misc :-) Thanks for valuable input Frank. This seems to work fine. (slightly more time consuming , but what do we have CPU power for ) library(Hmisc) library(sciplot) my.ci - function(x) c(smean.cl.boot(x)[2],smean.cl.boot(x)[3]) Don't double the executing time by running it twice! And this way you might possibly get an upper confidence interval that is lower than the lower one. Do function(x) smean.cl.boot(x)[-1] D'oh lineplot .CI (V1 ,V2 ,data = d ,col = c (4 ),err .col = c (1 ),err .width = 0.02 ,legend =FALSE,xlab=Timeofday,ylab=IOPS,ci.fun=my.ci,cex=0.5,lwd=0.7) Have I understood you correct in that this is a more accurate way of visualizing variability in any dataset , than the students T confidence intervals, because it does not assume normality ? Yes but instead of saying variability (which quantiles are good at) we are talking about the precision of the mean. Right. Can you explain the meaning of B, and how to find a sensible value (if not the default is sufficient) ? For most purposes the default is sufficient. There are great books and papers on the bootstrap for more info, including improved variations on the simple bootstrap percentile confidence interval used here. Frank Once again, thanks. Best regards - Jarle Bjørgeengen __ 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 wth boxplots
Hi I have a vector of data lets call zz (40 values from 4 samples) the data is already in groups, i can even split up the samples using SampA - zz[,2:11] SampB - zz[,12:21] SampC - zz[,22:31] SampV - zz[,32:41] I would like an output that gives me 4 boxplots on one plot one boxplot for the set of 10 values how can i do this in R __ 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] split strings
They look like file path, so you can make use of basename() first, then use gsub to strip the suffix. x-c(F:/Naval_Live_Oaks/2005/data//BE.tif,F:/Naval_Live_Oaks/2005/data//CH.tif) x2-sapply(x,basename,USE.NAMES=FALSE) gsub([.].{1,}$,,x2) [1] BE CH Ronggui 2009/5/26 Monica Pisica pisican...@hotmail.com: Hi everybody, I have a vector of characters and i would like to extract certain parts. My vector is named metr_list: [1] F:/Naval_Live_Oaks/2005/data//BE.tif [2] F:/Naval_Live_Oaks/2005/data//CH.tif [3] F:/Naval_Live_Oaks/2005/data//CRR.tif [4] F:/Naval_Live_Oaks/2005/data//HOME.tif And i would like to extract BE, CH, CRR, and HOME in a different vector named names.id for example. I read the help files for sub and grep and the likes but i have to recognize that i did not understand it. So i've done this (which does the job but extremely clumsy): b - strsplit(metr_list, //) b - unlist(b) d - strsplit(b, \\.) d - unlist(d) names.id - d[c(2, 5, 8, 11)] Can anybody show what would be the proper way to achieve this with some explanations? Thanks, Monica _ Hotmail® goes with you. ial_Mobile1_052009 __ 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. -- HUANG Ronggui, Wincent PhD Candidate Dept of Public and Social Administration City University of Hong Kong Home page: http://asrr.r-forge.r-project.org/rghuang.html __ 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] split strings
Try this: sub(.tif$, , basename(metr_list)) On Tue, May 26, 2009 at 9:27 AM, Monica Pisica pisican...@hotmail.com wrote: Hi everybody, I have a vector of characters and i would like to extract certain parts. My vector is named metr_list: [1] F:/Naval_Live_Oaks/2005/data//BE.tif [2] F:/Naval_Live_Oaks/2005/data//CH.tif [3] F:/Naval_Live_Oaks/2005/data//CRR.tif [4] F:/Naval_Live_Oaks/2005/data//HOME.tif And i would like to extract BE, CH, CRR, and HOME in a different vector named names.id for example. I read the help files for sub and grep and the likes but i have to recognize that i did not understand it. So i've done this (which does the job but extremely clumsy): b - strsplit(metr_list, //) b - unlist(b) d - strsplit(b, \\.) d - unlist(d) names.id - d[c(2, 5, 8, 11)] Can anybody show what would be the proper way to achieve this with some explanations? Thanks, Monica _ Hotmail® goes with you. ial_Mobile1_052009 __ 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] R under Ubuntu
On Tue, May 26, 2009 at 11:17 AM, Luis Ridao Cruz lu...@hav.fo wrote: R-help, I have installed R under Ubuntu and I'm very new to a Linux distribution. To open an empty R session I just type R on the Terminal aplication. But how can I open a saved workspace? At present I just start R and then load (my_workspace) but it must be possible to do it all at onceright? By default R will normally load a .RData file from the working directory where you start R. It will save this when you quit and say 'yes' to the Save workspace image? question. So if you make a working folder from the command line shell, change to that folder, and start R, it will pick up any .RData file that might be there. For example: mkdir foo cd foo R and it will use a .RData file there if there is one, and save the workspace there when you quit. Then you can do: cd .. mkdir bar cd bar R and you'll get a separate .RData file in subdirectory 'bar'. If you are a linux beginner then you might not have noticed files beginning with 'dot' - they are generally hidden by the 'ls' command unless you add the '-a' option (ie do ls -a). If you read the help(Startup) in R you'll see: It then loads a saved image of the user workspace from '.RData' if there is one (unless '--no-restore-data' or '--no-restore' was specified on the command line). Barry __ 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] split strings
Monica Pisica wrote: Hi everybody, I have a vector of characters and i would like to extract certain parts. My vector is named metr_list: [1] F:/Naval_Live_Oaks/2005/data//BE.tif [2] F:/Naval_Live_Oaks/2005/data//CH.tif [3] F:/Naval_Live_Oaks/2005/data//CRR.tif [4] F:/Naval_Live_Oaks/2005/data//HOME.tif And i would like to extract BE, CH, CRR, and HOME in a different vector named names.id one way that seems reasonable is to use sub: output = sub('.*//(.*)[.]tif$', '\\1', input) which says 'from each string remember the substring between the rigthmost two slashes and a .tif extension, exclusive, and replace the whole thing with the captured part'. if the pattern does not match, you get the original input: sub('.*//(.*)[.]tif$', '\\1', 'f:/foo/bar//buz.tif') # buz vQ __ 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 multiple graphs based on one variable
Tim Clark wrote: Dear List, I would like to create several graphs of similar data. I have x and y values for several different individuals (in this case fish). I would like to plot the x and y values for each fish separately. I can do it using a for loop, but I think I should be using apply. Please let me know what I am doing wrong, or if there is a better way to do this. What I have is: #Test data dat-data.frame(c(rep(1:10,4)),c(rep(1:10,4)),c(rep(c(Tony,Mike,Vicky,Fred),each=10))) names(dat)-c(x,y,Name) #Create function to plot x and y myplot-function() plot(dat$x,dat$y) #Apply the function to each of the names par(mfcol=c(2,2)) apply(dat,2,myplot,by=dat$Name) #Does not work - tried various versions I would like separate plots for Tony, Mike, and Vicky. What is the best way to do this? Thank! Tim Tim Clark Department of Zoology University of Hawaii __ 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. Hi Tim, I'm now rather fond of Hadley Wickham's ggplot2 package. Its structure is most of the times intuitive and it does yield nice-looking output. In order to solve your problem, taking advantage of the ggplot2 framework, you can simply use the following: library(ggplot2) ; ## If you want all the curves to be on the same plotting grid ; p - ggplot(dat, aes(x=x,y=y, group=Name)) ; p + geom_line(aes(colour=Name)) ; ## Only one curve will be visible since they are all superposed. ## If you want the curves to be on separate plotting grids ; p - ggplot(dat, aes(x=x,y=y, group=Name)) ; p - p + geom_line(aes(colour=Name)) ; p+facet_grid(. ~ Name) ; Hope this helps, -- *Luc Villandré* /Biostatistician McGill University Health Center - Montreal Children's Hospital Research Institute/ __ 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] Odp: help wth boxplots
Hi r-help-boun...@r-project.org napsal dne 26.05.2009 15:34:25: Hi I have a vector of data lets call zz (40 values from 4 samples) Are you sure it is a vector? Your indexing suggest data frame or matrix. the data is already in groups, i can even split up the samples using SampA - zz[,2:11] SampB - zz[,12:21] SampC - zz[,22:31] SampV - zz[,32:41] I would like an output that gives me 4 boxplots on one plot one boxplot for the set of 10 values how can i do this in R maybe boxplot(list(SampA, SampB, SampC, SampV)) but there are more effective ways if you had other data structure e.g. 4 column data frame boxplot(data.frame(rnorm(10), rnorm(10), rnorm(10), rnorm(10))) or list boxplot(list(rnorm(10), rnorm(10), rnorm(10), rnorm(10))) or even a vector of indices for different groups boxplot(split(rnorm(40), rep(letters[1:4],10)) Regards Petr __ 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 wth boxplots
check out ggplot2: http://had.co.nz/ggplot2/ particularly: http://had.co.nz/ggplot2/geom_boxplot.html On Tue, May 26, 2009 at 10:34 AM, Amit Patel amitrh...@yahoo.co.uk wrote: Hi I have a vector of data lets call zz (40 values from 4 samples) the data is already in groups, i can even split up the samples using SampA - zz[,2:11] SampB - zz[,12:21] SampC - zz[,22:31] SampV - zz[,32:41] I would like an output that gives me 4 boxplots on one plot one boxplot for the set of 10 values how can i do this in R __ 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. -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ __ 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] Timing issue using locator() in loop containing print()
With the suggestion of Jim Holtman I have successfully implemented the loop containing locator() using RGUI by toggling the buffer to OFF. However, I am using JavaGD and the loop still will not work so the Java graphics window is apparently buffered and I can't figure out how to turn it off. I really like Java JGR and its JavaGD. I haven't been able to get the info from www.rosuda.org so if anyone has solved this buffer problem with JavaGD I would appreciate a note. - Original Message - From: jim holtman To: Bob Meglen Cc: r-help@r-project.org Sent: Sunday, May 24, 2009 5:06 PM Subject: Re: [R] Timing issue using locator() in loop containing print() Is the output buffered on the RGUI? If so, uncheck it and see if the problem clears up. On Sun, May 24, 2009 at 3:24 PM, Bob Meglen bmeg...@comcast.net wrote: I am attempting to use locator(n=2) to select the corners of several (5 in this case) rectangles on an image displayed in a JavaGD window. The returned coords are used to draw labeled rectangles around the selected region. I have tried several things to get this to work including sys.Sleep to correct what appears to be a timing issue with this loop. The first-time print in the loop doesn't print before locator executes several mouse clicks, and the order of pt(1) and pt(2) in each execution of the loop gets out of sync. Please offer a suggestion. I am using Windows, Java Gui for R1.6-3, R version 2.8.1. Example: #..PLOT the Image in Java Window. JavaGD(name=JavaGD, width=640, height=480) #.suppress margins all around. par(mar=c(0,0,0,0)) image(xraw,col=my.grays(256),axes=F) #Set up loop.. tot_subsets-5 ss- matrix(0,nrow=tot_subsets,ncol=4) print(begin selections) # .Loop for multiple rectangle selections on image. for (i in 1:tot_subsets) { print(Select lower left and upper right for this rectangle) sub_0- locator(n=2) rect(sub_0$x[1],sub_0$y[1],sub_0$x[2],sub_0$y[2],col=red,density=0) text(sub_0$x[1]+(sub_0$x[2]-sub_0$x[1])/2,sub_0$y[1]+(sub_0$y[2]-sub_0$y[1])/2,paste(S,i),col=red) #...Add each reactangle coords to master subset list. ss[i,1]-sub_0$x[1] ss[i,2]-sub_0$y[1] ss[i,3]-sub_0$x[2] ss[i,4]-sub_0$y[2] } print(finished selection) Thanks, Bob Meglen Boulder, CO __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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] Discovery on packages
On 5/26/2009 10:25 AM, JannaB wrote: If I download a package -- how can I explore what it does? For instance, I downloaded the TTR package of off CRAN -- but how can I find out what it does? Is there a type of API doc for each package? JB If you ask for help using ?TTR, you'll get an overview page. This is a recommended convention for all packages, but not all of them do it. TTR did. Duncan Murdoch __ 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 me...!!!
have a read at these pdfs http://cran.r-project.org/other-docs.html you are likely to get a bashing for asking people to do your homework for you! Simon. - Original Message - From: abel1682 lizard_1...@yahoo.it To: r-help@r-project.org Sent: Tuesday, May 26, 2009 3:37 PM Subject: [R] Help me...!!! Hi to all...i'm a new R'user and i have to solve some exercies so i ask to tou for an help... 1.) How i can demonstrate in R that the limit for x--infinite of (1+1/x)^x is equal to e? 2.) if i have a vector of values how can i create a function that, applied to my vector, give me median, mean, Var and length togheter? 3.)Find the minimum of this function: f(x)=(x-3)^4 with the Newton method. 4.) Define a function that is able to calculate the geometric mean of a seriation: Sorry for all these questions... Thanks a lot!!!... -- View this message in context: http://www.nabble.com/Help-me...%21%21%21-tp23724167p23724167.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 me...!!!
http://www.r-project.org/posting-guide.html Basic statistics and classroom homework: R-help is not intended for these. On Tue, May 26, 2009 at 11:37 AM, abel1682 lizard_1...@yahoo.it wrote: Hi to all...i'm a new R'user and i have to solve some exercies so i ask to tou for an help... 1.) How i can demonstrate in R that the limit for x--infinite of (1+1/x)^x is equal to e? 2.) if i have a vector of values how can i create a function that, applied to my vector, give me median, mean, Var and length togheter? 3.)Find the minimum of this function: f(x)=(x-3)^4 with the Newton method. 4.) Define a function that is able to calculate the geometric mean of a seriation: Sorry for all these questions... Thanks a lot!!!... -- View this message in context: http://www.nabble.com/Help-me...%21%21%21-tp23724167p23724167.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. -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ __ 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 me...!!!
Is this homework? If so, please read the posting guide and note the part about homework. Specifically, Basic statistics and classroom homework: R-help is not intended for these. http://www.r-project.org/posting-guide.html abel1682 wrote: Hi to all...i'm a new R'user and i have to solve some exercies so i ask to tou for an help... 1.) How i can demonstrate in R that the limit for x--infinite of (1+1/x)^x is equal to e? 2.) if i have a vector of values how can i create a function that, applied to my vector, give me median, mean, Var and length togheter? 3.)Find the minimum of this function: f(x)=(x-3)^4 with the Newton method. 4.) Define a function that is able to calculate the geometric mean of a seriation: Sorry for all these questions... Thanks a lot!!!... -- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Dalla Lana School of Public Health University of Toronto email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.6057 __ 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] split strings
Hi everybody, Thank you for the suggestions and especially the explanation Waclaw provided for his code. Maybe one day i will be able to wrap my head around this. Thanks again, Monica Date: Tue, 26 May 2009 15:46:21 +0200 From: waclaw.marcin.kusnierc...@idi.ntnu.no To: pisican...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] split strings Monica Pisica wrote: Hi everybody, I have a vector of characters and i would like to extract certain parts. My vector is named metr_list: [1] F:/Naval_Live_Oaks/2005/data//BE.tif [2] F:/Naval_Live_Oaks/2005/data//CH.tif [3] F:/Naval_Live_Oaks/2005/data//CRR.tif [4] F:/Naval_Live_Oaks/2005/data//HOME.tif And i would like to extract BE, CH, CRR, and HOME in a different vector named names.id one way that seems reasonable is to use sub: output = sub('.*//(.*)[.]tif$', '\\1', input) which says 'from each string remember the substring between the rigthmost two slashes and a .tif extension, exclusive, and replace the whole thing with the captured part'. if the pattern does not match, you get the original input: sub('.*//(.*)[.]tif$', '\\1', 'f:/foo/bar//buz.tif') # buz vQ _ Hotmail® goes with you. ial_Mobile1_052009 __ 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] Discovery on packages
If I download a package -- how can I explore what it does? For instance, I downloaded the TTR package of off CRAN -- but how can I find out what it does? Is there a type of API doc for each package? JB __ 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 me...!!!
Hi to all...i'm a new R'user and i have to solve some exercies so i ask to tou for an help... 1.) How i can demonstrate in R that the limit for x--infinite of (1+1/x)^x is equal to e? 2.) if i have a vector of values how can i create a function that, applied to my vector, give me median, mean, Var and length togheter? 3.)Find the minimum of this function: f(x)=(x-3)^4 with the Newton method. 4.) Define a function that is able to calculate the geometric mean of a seriation: Sorry for all these questions... Thanks a lot!!!... -- View this message in context: http://www.nabble.com/Help-me...%21%21%21-tp23724167p23724167.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] Discovery on packages
Janna - Another thing that's sometimes useful with a new package is to run the example function, like example(TTR) This will run the examples from the documentation to give you a quick idea of what the package can do. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Tue, 26 May 2009, JannaB wrote: If I download a package -- how can I explore what it does? For instance, I downloaded the TTR package of off CRAN -- but how can I find out what it does? Is there a type of API doc for each package? JB __ 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] degree symbol using X11 on OSX
Howdy, Using the scheme in plotmath, I can no longer get the degree symbol for my on-screen plots, using X11 on OS X. I instead see an upper- case upsilon (I think). This is reproducible using demo(plotmath). A figure drawn with this faulty symbol produces correct postscript (i.e. with a degree symbol) when I use dev.copy to write it to an eps file. I'm using R version 2.8.1 Patched (2009-01-19 r47650) on an intel Mac, fully updated OS X 10.5.7. Help appreciated, Andy -- Andy Jacobson andy.jacob...@noaa.gov NOAA Earth System Research Lab Global Monitoring Division 325 Broadway Boulder, Colorado 80305 303/497-4916 __ 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 create all pairs
Thanks guys! expand.grid looks like the thing I need. Meanwhile, I also came up with an alternative way of doing it using rep and cbind. pairwise - function(a,b) { aa = rep(a, each=length(b)) cbind(aa,b) } On Mon, May 25, 2009 at 9:52 PM, Mike Lawrence mike.lawre...@dal.ca wrote: expand.grid(i,j) On Mon, May 25, 2009 at 8:26 PM, alad abhimanyu...@gmail.com wrote: Hi, I have: i = c(1,2,3) j = c(4,5,6) How do I create a matrix of all pairs? i.e. 1,4 1,5 1,6 2,4 : Thanks! -- View this message in context: http://www.nabble.com/How-to-create-all-pairs-tp23714659p23714659.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. -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ [[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] long format - find age when another variable is first 'high'
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Marc Schwartz Sent: Monday, May 25, 2009 6:52 AM To: David Freedman Cc: r-help@r-project.org Subject: Re: [R] long format - find age when another variable is first 'high' On May 25, 2009, at 7:45 AM, David Freedman wrote: Dear R, I've got a data frame with children examined multiple times and at various ages. I'm trying to find the first age at which another variable (LDL-Cholesterol) is = 130 mg/dL; for some children, this may never happen. I can do this with transformBy and ddply, but with 10,000 different children, these functions take some time on my PCs - is there a faster way to do this in R? My code on a small dataset follows. Thanks very much, David Freedman d-data.frame(id=c(rep(1,3),rep(2,2), 3),age=c(5,10,15,4,7,12),ldlc=c(132,120,125,105,142,160)) d$high.ldlc-ifelse(d$ldlc=130,1,0) d library(plyr) d2-ddply(d,~id,transform,plyr.minage=min(age[high.ldlc==1])); library(doBy) d2-transformBy(~id,da=d2,doby.minage=min(age[high.ldlc==1])); d2 The first thing that I would do is to get rid of records that are not relevant to your question: d id age ldlc high.ldlc 1 1 5 132 1 2 1 10 120 0 3 1 15 125 0 4 2 4 105 0 5 2 7 142 1 6 3 12 160 1 # Get records with high ldl d.new - subset(d, ldlc = 130) d.new id age ldlc high.ldlc 1 1 5 132 1 5 2 7 142 1 6 3 12 160 1 That will help to reduce the total size of the dataset, perhaps substantially. It will also remove entire subjects that are not relevant (eg. never have LDL = 130). Then get the minimum age for each of the remaining subjects: aggregate(d.new$age, list(id = d.new$id), min) id x 1 1 5 2 2 7 3 3 12 If the dataset has a lot of rows you can save more time by replacing the call to aggregate(age,id,min) by code that sorts the filtered data by 'id' then breaking ties with 'age', and then picking out the elements just after a change in the value of 'id': f - function(d) { dSorted - d[ order(d$id,d$age),] n - length(d$id) # or nrow(d) dSorted[ c(TRUE, dSorted$id[-1] != dSorted$id[-n]), ] } f(d.new) # or f(d[d$ldlc=130,]) to avoid leaving around the temp variable. If you know your dataset is already sorted in this way, you just need only the last line of that function. Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com Try that to see what sort of time reduction you observe. HTH, Marc Schwartz __ 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] using lsoda() and nls() together
Thanks to Dieter Menne and Spencer Graves I started to get my way through lsoda() Now I need to use it in with nls() to assess parameters I have a go with a basic example dy/dt = K1*conc I try to assess the value of K1 from a simulated data set with a K1 close to 2. Here is (I think) the best code that I've done so far even though it crashes when I call nls() -- x-seq(0,10,,100) y-exp(2*x) y-rnorm(y,y,0.3*y) test.model-function(t,conc,parms){ dy.dt = parms[K1]*conc list(dy.dt) } require(deSolve) foo-lsoda(c(conc=1),times=seq(0,10,,100),test.model,parms=c(K1=2)) foo #use of nls func-function(K1) { foo-lsoda(c(conc=1),times=seq(0,10,,100),test.model,parms=c(K1=K1)) foo[,conc] } nls(foo~func(K1),start=list(K1=1),data=data.frame(foo=y)) # have a look on the SSD # y is the vector of real data SSD-function(K1) { sum((y-func(K1))^2) } data-seq(1.5,2.1,,100) plot(data,sapply(data,SSD),type=l) -- Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : spencerg [mailto:spencer.gra...@prodsyse.com] Envoyé : vendredi 15 mai 2009 05:28 À : Benoit Boulinguiez Cc : dieter.me...@menne-biomed.de; r-help@r-project.org Objet : Re: [R] ode first step Have you looked at the vignette in the deSolve package? (deS - vignette('compiledCode')) # opens a pdf file Stangle(deS$file) # writes an R script file to getwd() In spite of the name, this vignette includes an example entirely in R. By comparing it with your code, I see that you do NOT provide a connection between y, parms, K1, C0, m, V, K2 and q. Something like the following might work: kinetic.model-function(t,y,parms){ dq.dt = parms['K1']*y['C0'] - (parms['K1']*y['m']/y['V']+ parms['K2'])*y['q'] list(dq.dt) } This may not be correct, but I hope the changes will help you see how to make it work. Bon Chance. Spencer Graves Benoit Boulinguiez wrote: As I do not thoroughly understand the way 'lsoda' works, I face some difficulties to 'get' myself into the function(), though I changed the code as follows: -- require(deSolve) qm-0.36 y0-c(0) parms-c(K1,K2) times-seq(0,1,1) kinetic.model-function(t,y,parms){ dq.dt = K1*C0 - (K1*m/V+ K2)*q list(dq.dt) } foo-lsoda(y0,times,kinetic.model,parms) Error in func(time, state, parms, ...) : object 'K1' not found -- 'K1' and 'K2' are parameters but 'C' is not a parameter, it's a dependant variable of the time. I actually express it as a function of q(t) to get this new equation dq/dt= K1*C0 - (K1*m/V+ K2)*q(t) where K1 and K2 are the unknown but desired parameters and {C0,m,V} are constant known values. Nevertheless, I still get this 'Error about object 'K1' not found'. Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : Dieter Menne [mailto:dieter.me...@menne-biomed.de] Envoyé : jeudi 14 mai 2009 12:12 À : 'Benoit Boulinguiez' Objet : RE: [R] ode first step Try to hide yourself inside the function(). What would you see? No K1, for sure, no C, no K2. These are passed through parms, so parms[K1] would work, but not for C, you should add it. -Original Message- From: Benoit Boulinguiez [mailto:benoit.boulingu...@ensc-rennes.fr] Sent: Thursday, May 14, 2009 11:53 AM To: 'Dieter Menne' Subject: RE: [R] ode first step -- qm-0.36 y0-c(0) parms-c(K1=1,K2=1) times-seq(0,1,1) kinetic.model-function(t,y,parms){ dq.dt- K1*C*(qm-q)-K2*q list(dq.dt) } require(deSolve) nls(foo-lsoda(y0,times,kinetic.model,parms) __ 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] Bootstrapping and estimation of standard error
Hello, I've started using R few months ago and I really like it. I need to estimate standard deviation of certain statistics (some measures of poverty). I found a really simple program, and I just need to check whether it's OK and really calculates what it's supposed to. Let's suppose e. g. head-count index (as one of the simplest measures of poverty) which is calculated as a proportion: q/n, where q is the number of poor and n is the size of population. This can be easily programmed e. g. as: headcount - function(x=1:10) { y - x[x 9] H - (length(y)/length(x)) c(h_index = H) } There are probably also other ways how to do it, but I'm just the beginner :-) . (FYI: x is the vector of income data and 9 is the poverty line). Then one of possibilities how to estimate the standard deviation is bootstrapping. I found a simple program: resamples.h - lapply(1:1000, function(i) sample(size = 100, silc$prijem, replace = T)) r.headcount - sapply(resamples.h, headcount) Then it's easy to estimate S.E. So my first question is whether this might be correct. Then I would like to ask, how the number of replications (in this case 1000) and size of the sample (samples of size 100, the real sample was about 5000) can influence the results. Or how can those two values be substantiated? Is it just subjective or are there any methods how to assess those values? I really appreciate your time and help. Thanks a lot. Tomas __ 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] Linear Regression with Constraints
Hi! I am a bit new to R. I am looking for the right function to use for a multiple regression problem of the form: y = c1 + x1 + (c2 * x2) - (c3 * x3) Where c1, c2, and c3 are the desired regression coefficients that are subject to the following constraints: 0.0 c2 1.0, and 0.0 c3 1.0 y, x1, x2, and x3 are observed data. I have a total of 6 rows of data in a data set. Is optim in the stats package the right function to use? Also, I can't quite figure out how to specify the constraints. Thank you! -Stu __ 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] R for arma mdel with constraints on parameters
See the 'fixed' argument, which allows you to fix ARIMA parameters at any value, including zero. On Tue, 26 May 2009, FangTonggen wrote: Hi, i am learning R recently and find it very helpful in time series model. In ARMA model, given (p,q) it can get the estimation of a[i] and b[j] easily with arima() function. X[t] = a[1]X[t-1] + ... + a[p]X[t-p] + e[t] + b[1]e[t-1] + ... + b[q]e[t-q] but in my recent data model, i met a problem. In the ARMA model, p and q are fixed, but there are some constraints in the parameters a[i] and b[j], such as for some i (ip), a[i]=0. my problem is how to get these parameters' estimation for these constrants with arima() function? or i need to write functions to realize it. Best regards, Tongen from Beijing -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 me...!!!
The bad news, as others have indicated, is that this list is not for homework. The good news is that all of this is extremely easy in R!!! -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of abel1682 Sent: Tuesday, May 26, 2009 10:37 AM To: r-help@r-project.org Subject: [R] Help me...!!! Hi to all...i'm a new R'user and i have to solve some exercies so i ask to tou for an help... 1.) How i can demonstrate in R that the limit for x--infinite of (1+1/x)^x is equal to e? 2.) if i have a vector of values how can i create a function that, applied to my vector, give me median, mean, Var and length togheter? 3.)Find the minimum of this function: f(x)=(x-3)^4 with the Newton method. 4.) Define a function that is able to calculate the geometric mean of a seriation: Sorry for all these questions... Thanks a lot!!!... -- View this message in context: http://www.nabble.com/Help-me...%21%21%21-tp23724167p23724167.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] Problem accessing row number from subset on a dataframe
I would like to use the row number information returned from performing a subset command on a dataframe. For example, I would like to automatically delete some rows from a dataframe if they match a criteria. Here is my example below. data(airquality) names(airquality) subset(airquality, airquality$Month == 6) Now how do I delete the row numbers returned automatically? I know I can type airquality_mod-airquality[-c(32:60)] However, I would like to check the row information and then use it to delete the stuff out of the dataframe. Thank again for any feedback and insights. __ 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] optim() question
I've seen with other software the capability for the optimizer to switch algorithms if it is not making progress between iterations. Is this capability available in optim()? Thanks, Stephen Collins, MPP | Analyst Health Benefits | Aon Consulting [[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] Linear Regression with Constraints
Here is a demonstration of how to solve your problem : n - 30 # You might need more than 6 data points to get good estimates for 3 parameters x1 - rnorm(n) x2 - runif(n) x3 - rbinom(n, size=1, prob=0.4) A - cbind(x1, x2, x3) # 30 x 3 matrix of independent variables b - c(-1, 0.5, 0.2) # Note: the last component is out of bounds! y - A %*% b + rnorm(n, sd=0.1) qr.solve(A, y) # unconstrained LS solution # Implementing the bounds (there is probably a better way to do this) # nc - ncol(A) c1 - matrix(0, nc, nc) diag(c1) - 1 c2 - matrix(0, nc, nc) diag(c2) - -1 cmat - rbind(c1, c2) Cmat - cmat[c(2,5,3,6), ] # Constraint matrix G b0 - c(0, -1, -1, 0) require(limSolve) ans - lsei(A = A, B = y, G = Cmat, H = b0) ans While ans$X gives you the point estimates, it is a bit tricky to get standard errors. Hope this helps, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Stu @ AGS Sent: Tuesday, May 26, 2009 2:12 PM To: r-help@r-project.org Subject: [R] Linear Regression with Constraints Hi! I am a bit new to R. I am looking for the right function to use for a multiple regression problem of the form: y = c1 + x1 + (c2 * x2) - (c3 * x3) Where c1, c2, and c3 are the desired regression coefficients that are subject to the following constraints: 0.0 c2 1.0, and 0.0 c3 1.0 y, x1, x2, and x3 are observed data. I have a total of 6 rows of data in a data set. Is optim in the stats package the right function to use? Also, I can't quite figure out how to specify the constraints. Thank you! -Stu __ 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] interactive file choosing in Linux?
I am used to using the [R] function choose.files() for interactive file selection in MS-Windows. What is the comparable function in Linux? I expected the function file.choose() to display similar behavior, i.e., a graphical interface diplaying a file listing, but all I seem to get is a text input prompt. This does not seem correct. file.choose() Enter file name: I have seen gfile() function in the gWidgets library - but isn't there anything native? Thank you! Derek Eder Linux: Ubuntu 9.04, Gnome, [R] running in terminal or ESS GTK_Emacs (doesn't make any difference to the above). version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 8.1 year 2008 month 12 day 22 svn rev 47281 language R version.string R version 2.8.1 (2008-12-22) Derek N. Eder Gothenburg University Vigilance and Neurocognition Laboratory Medicinaregatan 8B Gothenburg Sweden SE 405 30 tlf (031) 342-8261 mobil 0704 915 714 All created things are impermanent — Strive diligently. __ 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] interactive file choosing in Linux?
Hi, You might like tk_choose.files from package tcltk. This comes with R but your system needs to be capable enough: capabilities( )[tcktk] require( tcltk ) tk_choose.files Romain Derek Eder wrote: I am used to using the [R] function choose.files() for interactive file selection in MS-Windows. What is the comparable function in Linux? I expected the function file.choose() to display similar behavior, i.e., a graphical interface diplaying a file listing, but all I seem to get is a text input prompt. This does not seem correct. file.choose() Enter file name: I have seen gfile() function in the gWidgets library - but isn't there anything native? Thank you! Derek Eder Linux: Ubuntu 9.04, Gnome, [R] running in terminal or ESS GTK_Emacs (doesn't make any difference to the above). version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 8.1 year 2008 month 12 day22 svn rev47281 language R version.string R version 2.8.1 (2008-12-22) Derek N. Eder Gothenburg University Vigilance and Neurocognition Laboratory Medicinaregatan 8B Gothenburg Sweden SE 405 30 tlf (031) 342-8261 mobil 0704 915 714 All created things are impermanent — Strive diligently. __ 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. -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr __ 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] (OT) Does pearson correlation assume bivariate normality of the data?
Dear all, The other day I was reading this post [1] that slightly surprised me: To reject the null of no correlation, an hypothsis test based on the normal distribution. If normality is not the base assumption your working from then p-values, significance tests and conf. intervals dont mean much (the value of the coefficient is not reliable) (BOB SAMOHYL). To me this implied that in practice Pearson's product-moment correlation (and associated significance) is often used incorrectly . Then I went wrestling with the literature, and with my friends on what does the Pearson correlation actually impose, and after about a week I'm still head-banging against divergent opinions. From what I understand there are two aspects to this classical parametric procedure: 1. Estimating the magnitude of the correlation: - the sample data should come from a bivariate normal distribution (?cor, ?cor.test, Dalgaard 2003, somewhat implied in many examples such as ?rrcov::maryo or Wilcox 2005) - the sample data should be (I presume univariate) normal (Crawley 2007) - the sample data can be of any distribution (if I understand correctly the `distribution-free' definition of correlation in Huber 1981, 2004) - the sample data could come from just about any bivariate distribution (Wikipedia [2][3] and associated reference) - the coefficient is (very) not robust to univariate outliers (e.g., Huber 1981), and to multivariate outliers (?rrcov::maryo with data from Marona and Yohai 1998) 2. Assessing whether the correlation is significantly different from zero (using a statistic following the t distribution): - the data should come from independent normal distributions (?cor.test) - at least one of the marginal distributions is normal (Wilcox 2005) Surprisingly (to me) many sources seem quite evasive on clearly defining the pearson correlation. Reading the literature I was pretty much convinced that the correlation coefficient is not robust to outliers. The literature is also convincing on the impact of contaminated normal, heavy-tailed distributions on parametric tests (invalidating their results). However, I'm not clear on the distributional assumptions on the data: - does the data have to be bivariate normal in order to correctly estimate the linear correlation? - does the data have to be univariate normal in order to correctly estimate the significance of the correlation? If the above is true, what are the preferable alternatives for non-gaussian data (including heavy-tailed normal)? non-parametric tests (spearman, kendall)? the robust MASS::cov.mcd, rrcov::CovOgk, robust::covRob()? hypothesis testing via Permutation Tests [4]? is there a robust cor.test? other robust tests of independence? Thank you, Liviu [1] http://www.nabble.com/Correlation-on-Tick-Data-tp18589474p18595197.html [2] http://en.wikipedia.org/wiki/Correlation#Sensitivity_to_the_data_distribution [3] http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient#Sensitivity_to_the_data_distribution [4] http://www.burns-stat.com/pages/Tutor/bootstrap_resampling.html#permtest -- Do you know how to read? http://www.alienetworks.com/srtest.cfm Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ 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] NNET conditional Multinomial logit
Please, could you tell me how to enter a mixed or a purely conditional multinomial logit model in NNET. I know how to do a multinomial logit in NNET but I don't know how to do conditional or mixed models using this package. I do know how to do this with VGAM - but would like to compare my results to those obtained by NNET. Thanks. Raffaele. _ s. It's easy! aspxmkt=en-us [[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] Problem accessing row number from subset on a dataframe
Hi. I may be missing what you're trying to achieve, but... what about subset(airquality, airquality$Month!=6) instead? You can do arbitrarily complex queries if you wish, combining terms logically. You don't have to use the subset function. You may find it helpful to see what the following result in: airquality$Month==6 airquality[airquality$Month==6, ] airquality[airquality$Month==6, ] There are ways of getting the row numbers, but I suspect you don't actually need to do that, do you? Best wishes, Mark 2009/5/26 Jason Rupert jasonkrup...@yahoo.com: I would like to use the row number information returned from performing a subset command on a dataframe. For example, I would like to automatically delete some rows from a dataframe if they match a criteria. Here is my example below. data(airquality) names(airquality) subset(airquality, airquality$Month == 6) Now how do I delete the row numbers returned automatically? I know I can type airquality_mod-airquality[-c(32:60)] However, I would like to check the row information and then use it to delete the stuff out of the dataframe. Thank again for any feedback and insights. __ 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. -- Dr. Mark Wardle Specialist registrar, Neurology Cardiff, UK __ 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] Still can't find missing data
I'm trying to prepare some cross tabs, looking at a number of variables against a variable connector which has 2 values: OD Passenger and Connector. When I produce a xtabs one way I have observations under Connector but against a different variable Connector shows all 0 values. What is wrong? I've looked into the na commands and the ?xtabs entry, but I haven't found anything that works. # XTTable - xtabs(wt_annual ~ time_strata + connector, LAWAData) XTTable ## List connector time_strata OD Passenger Connector Morning Peak - 0550 to 09595605.140 1234.933 Late morning to Mid-Day - 1000 to 1359 4778.503 2516.943 Evening Peak - 1400 to 19595145.730 3171.348 Night - 2000 to 0235 (last flight) 2929.085 2567.790 XTTable - xtabs(wt_annual ~ Mode_orig_only + connector, exclude=NULL, LAWAData) XTTable ## List connector Mode_orig_only OD Passenger Connector Walked/Biked17.814338 0.00 I flew in from another a place/connected0.00 0.00 Amtrak 49.128982 0.00 Bus - Chartered bus or van 525.978899 0.00 Bus - Hotel Courtesy van 913.295370 0.00 Bus - MTA (Metro) or other public transit bus 114.302764 0.00 Bus - Scheduled airport bus or van (e.g. Airport bus or Disn 298.151438 0.00 Bus - Union Station Flyaway 93.088049 0.00 Bus - Van Nuys Flyaway 233.794168 0.00 Green line/light rail 20.764539 0.00 Limousine/town car 424.120506 0.00 Metrolink8.054528 0.00 Motorcycle 6.010790 0.00 On-call shuttle/van (e.g. Super Shuttle, Prime Time) 1832.748525 0.00 Car/truck/van - Private 10191.284139 0.00 Car/truck/van - Rental2099.771923 0.00 Taxi 1630.148576 0.00 ..Refused0.00 0.00 XTTable - xtabs(wt_annual ~ Mode_orig_only + connector, na.action(na.pass), LAWAData) Error in eval(expr, envir, enclos) : object wt_annual not found XTTable ## List connector Mode_orig_only OD Passenger Connector Walked/Biked17.814338 0.00 I flew in from another a place/connected0.00 0.00 Amtrak 49.128982 0.00 Bus - Chartered bus or van 525.978899 0.00 Bus - Hotel Courtesy van 913.295370 0.00 Bus - MTA (Metro) or other public transit bus 114.302764 0.00 Bus - Scheduled airport bus or van (e.g. Airport bus or Disn 298.151438 0.00 Bus - Union Station Flyaway 93.088049 0.00 Bus - Van Nuys Flyaway 233.794168 0.00 Green line/light rail 20.764539 0.00 Limousine/town car 424.120506 0.00 Metrolink8.054528 0.00 Motorcycle 6.010790 0.00 On-call shuttle/van (e.g. Super Shuttle, Prime Time) 1832.748525 0.00 Car/truck/van - Private 10191.284139 0.00 Car/truck/van - Rental2099.771923 0.00 Taxi 1630.148576 0.00 ..Refused0.00 0.00 XTTable - xtabs(wt_annual ~ Mode_orig_only + connector, drop.unused.levels = FALSE, LAWAData) XTTable ## List
Re: [R] split strings
Monica Pisica wrote: Hi everybody, Thank you for the suggestions and especially the explanation Waclaw provided for his code. Maybe one day i will be able to wrap my head around this. Thanks again, you're welcome. note that if efficiency is an issue, you'd better have perl=TRUE there: output = sub('.*//(.*)[.]tif$', '\\1', input, perl=TRUE) with perl=TRUE, the one-pass solution is somewhat faster than the two-pass solution of gabor's -- which, however, is probably easier to understand; with perl=FALSE (the default), the performance drops: strings = sprintf( 'f:/foo/bar//%s.tif', replicate(1000, paste(sample(letters, 10), collapse=''))) library(rbenchmark) benchmark(columns=c('test', 'elapsed'), replications=1000, order=NULL, 'one-pass, perl'=sub('.*//(.*)[.]tif$', '\\1', strings, perl=TRUE), 'two-pass, perl'=sub('.tif$', '', basename(strings), perl=TRUE), 'one-pass, no perl'=sub('.*//(.*)[.]tif$', '\\1', strings, perl=FALSE), 'two-pass, no perl'=sub('.tif$', '', basename(strings), perl=FALSE)) # 1one-pass, perl 3.391 # 2two-pass, perl 4.944 # 3 one-pass, no perl 18.836 # 4 two-pass, no perl 5.191 vQ Monica Date: Tue, 26 May 2009 15:46:21 +0200 From: waclaw.marcin.kusnierc...@idi.ntnu.no To: pisican...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] split strings Monica Pisica wrote: Hi everybody, I have a vector of characters and i would like to extract certain parts. My vector is named metr_list: [1] F:/Naval_Live_Oaks/2005/data//BE.tif [2] F:/Naval_Live_Oaks/2005/data//CH.tif [3] F:/Naval_Live_Oaks/2005/data//CRR.tif [4] F:/Naval_Live_Oaks/2005/data//HOME.tif And i would like to extract BE, CH, CRR, and HOME in a different vector named names.id one way that seems reasonable is to use sub: output = sub('.*//(.*)[.]tif$', '\\1', input) which says 'from each string remember the substring between the rigthmost two slashes and a .tif extension, exclusive, and replace the whole thing with the captured part'. if the pattern does not match, you get the original input: sub('.*//(.*)[.]tif$', '\\1', 'f:/foo/bar//buz.tif') # buz vQ _ __ 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] OWL (Web Ontology Language) in R?
Is anyone working on an R package for manipulating OWL (Web Ontology Language), either natively or via an external library? I don't see anything obviously relevant in CRAN, though of course OWL functionality could be built up starting with the XML package. Thanks, -s [[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] split strings
Although speed is really immaterial here this is likely to be faster than all shown so far: sub(.tif, , basename(metr_list), fixed = TRUE) It does not allow file names with .tif in the middle of them since it will delete the first occurrence rather than the last but such a situation is highly unlikely. On Tue, May 26, 2009 at 4:24 PM, Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote: Monica Pisica wrote: Hi everybody, Thank you for the suggestions and especially the explanation Waclaw provided for his code. Maybe one day i will be able to wrap my head around this. Thanks again, you're welcome. note that if efficiency is an issue, you'd better have perl=TRUE there: output = sub('.*//(.*)[.]tif$', '\\1', input, perl=TRUE) with perl=TRUE, the one-pass solution is somewhat faster than the two-pass solution of gabor's -- which, however, is probably easier to understand; with perl=FALSE (the default), the performance drops: strings = sprintf( 'f:/foo/bar//%s.tif', replicate(1000, paste(sample(letters, 10), collapse=''))) library(rbenchmark) benchmark(columns=c('test', 'elapsed'), replications=1000, order=NULL, 'one-pass, perl'=sub('.*//(.*)[.]tif$', '\\1', strings, perl=TRUE), 'two-pass, perl'=sub('.tif$', '', basename(strings), perl=TRUE), 'one-pass, no perl'=sub('.*//(.*)[.]tif$', '\\1', strings, perl=FALSE), 'two-pass, no perl'=sub('.tif$', '', basename(strings), perl=FALSE)) # 1 one-pass, perl 3.391 # 2 two-pass, perl 4.944 # 3 one-pass, no perl 18.836 # 4 two-pass, no perl 5.191 vQ Monica Date: Tue, 26 May 2009 15:46:21 +0200 From: waclaw.marcin.kusnierc...@idi.ntnu.no To: pisican...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] split strings Monica Pisica wrote: Hi everybody, I have a vector of characters and i would like to extract certain parts. My vector is named metr_list: [1] F:/Naval_Live_Oaks/2005/data//BE.tif [2] F:/Naval_Live_Oaks/2005/data//CH.tif [3] F:/Naval_Live_Oaks/2005/data//CRR.tif [4] F:/Naval_Live_Oaks/2005/data//HOME.tif And i would like to extract BE, CH, CRR, and HOME in a different vector named names.id one way that seems reasonable is to use sub: output = sub('.*//(.*)[.]tif$', '\\1', input) which says 'from each string remember the substring between the rigthmost two slashes and a .tif extension, exclusive, and replace the whole thing with the captured part'. if the pattern does not match, you get the original input: sub('.*//(.*)[.]tif$', '\\1', 'f:/foo/bar//buz.tif') # buz vQ _ __ 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 accessing row number from subset on a dataframe
Mark, I really apprecaite your response and continue to be amazed by the responsiveness and support on the R forums. And, well actually, I would like to get the row number(s) and then delete or not via the row number. Again, I really appreciate the response... --- On Tue, 5/26/09, Mark Wardle m...@wardle.org wrote: From: Mark Wardle m...@wardle.org Subject: Re: [R] Problem accessing row number from subset on a dataframe To: Jason Rupert jasonkrup...@yahoo.com Cc: R-help@r-project.org Date: Tuesday, May 26, 2009, 3:18 PM Hi. I may be missing what you're trying to achieve, but... what about subset(airquality, airquality$Month!=6) instead? You can do arbitrarily complex queries if you wish, combining terms logically. You don't have to use the subset function. You may find it helpful to see what the following result in: airquality$Month==6 airquality[airquality$Month==6, ] airquality[airquality$Month==6, ] There are ways of getting the row numbers, but I suspect you don't actually need to do that, do you? Best wishes, Mark 2009/5/26 Jason Rupert jasonkrup...@yahoo.com: I would like to use the row number information returned from performing a subset command on a dataframe. For example, I would like to automatically delete some rows from a dataframe if they match a criteria. Here is my example below. data(airquality) names(airquality) subset(airquality, airquality$Month == 6) Now how do I delete the row numbers returned automatically? I know I can type airquality_mod-airquality[-c(32:60)] However, I would like to check the row information and then use it to delete the stuff out of the dataframe. Thank again for any feedback and insights. __ 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. -- Dr. Mark Wardle Specialist registrar, Neurology Cardiff, UK __ 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] Sample size calculation proportions with EpiR: Discrepancy to other calculators
On Tue, 26 May 2009, Chuck Cleland wrote: On 5/26/2009 2:53 AM, Karl Knoblick wrote: Hallo! I have done a sample size calculation for proportions with EpiR. The input is: treatment group rate p=0.65 control group rate p=0.50 significance level 0.95 power 0.80 two-sided ration group 1 and 2: 1.0 I have done this in the following way: library(epiR) epi.studysize(treat = 0.65, control = 0.5, n = NA, sigma = NA, power = 0.80, r = 1, conf.level = 0.95, sided.test = 2, method = proportions) Result: $n [1] 82 PASS 2002 and NQuery give both 170 subjects per group without continuity correction. With continuity correction 183 per group. Looking at http://statpages.org/proppowr.html I get 182 subjects per group (with continuity correction, I admit). What am I doing wrong? Can anybody explain this? epi.studysize(treat = .65, control = .50, n = NA, sigma = NA, power = 0.80, r = 1, conf.level = 0.95, sided.test = 2, method = cohort) gives the same sample size as PASS 2002 and NQuery (170 per group). And simulation confirms that the larger numbers are correct. I don't know what is happening with epi.studysize(,method=proportion). epi.studysize(,method=cohort) doesn't seem exactly appropriate, since judging from the example on the help page the inputs are supposed to be cumulative incidence rather than probabilities. -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle __ 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] (OT) Does pearson correlation assume bivariate normality of the data?
This is the sort of problem (another related one is the assumptions of the t-test) that attracts a lot of relatively inefficient argument. Some basic points 1. If random variables X and Y are uncorrelated (and have finite moments, but that's a purely technical issue), the distribution of the Pearson correlation coefficient in samples from X and Y will be Normal with mean zero in large samples. No further assumption about distribution is needed. So, the test is valid in sufficiently large samples. 2. Similarly, the sample correlation coefficient between two random variables X and Y is a consistent estimator of the correlation between X and Y. Here the distribution [needed for confidence intervals] does depend on the distributions of X and Y, but by less than you might expect. For example, I found that Fisher's z-transformation and a t-distribution with n-3 df is a pretty good approximation to the distribution of correlation between lognormal random variables (a model for air pollution data) with a sample size of 10. 3. If X and Y are bivariate Normal and uncorrelated, they must be independent, so the null hypothesis of zero correlation is especially interesting for Normal data. 4. Zero correlation may still be an interesting null hypothesis without bivariate Normality -- if you don't know much about X and Y it may be an advance to be able to establish that Y tends to be higher when X is higher. 5. The correlation coefficient is sensitive to outlying observations. This is not necessarily a bad thing, but it means that if X and Y both have long-tailed distributions the test for zero correlation will be sensitive primarily to the tails. 6. If the tails of the distribution are mostly gross-error contamination, the sensitivity to the tails is bad. 7. The various robust or rank-based correlations don't estimate the same thing, any more than the mean and median estimate the same thing. They don't necessarily even have to have the same sign. Some of them are intended for bivariate Normal data with gross-error contamination, which is fine if that is what you have. Kendall's tau at least has a sensible interpretation that doesn't depend on distributions, whereas it's not clear to me why the hypothesis of zero Spearman correlation would be interesting without distributional assumptions. 8. Permutation tests will give you an exact small-sample test of *independence*, not of zero correlation. The test is not exact (it may be conservative or anticonservative) if X and Y are dependent but uncorrelated. The test has power only against alternatives where the correlation is non-zero. Some of the issues behind the confusion are the same as for the t-test: - a confusion of necessary vs sufficient assumptions - a confusion of long-tailed distributions and gross error contamination - worrying about the meaning of the null hypothesis only for 'parametric' tests and not for 'non-parametric tests' - not understanding that permutation tests have assumptions. There is also some genuine and informed disagreement about the relative importance of potential problems. Some of this disagreement is about philosophical issues, and some is about the likely pratical impact, which depends a lot on the setting. -thomas On Tue, 26 May 2009, Liviu Andronic wrote: Dear all, The other day I was reading this post [1] that slightly surprised me: To reject the null of no correlation, an hypothsis test based on the normal distribution. If normality is not the base assumption your working from then p-values, significance tests and conf. intervals dont mean much (the value of the coefficient is not reliable) (BOB SAMOHYL). To me this implied that in practice Pearson's product-moment correlation (and associated significance) is often used incorrectly . Then I went wrestling with the literature, and with my friends on what does the Pearson correlation actually impose, and after about a week I'm still head-banging against divergent opinions. From what I understand there are two aspects to this classical parametric procedure: 1. Estimating the magnitude of the correlation: - the sample data should come from a bivariate normal distribution (?cor, ?cor.test, Dalgaard 2003, somewhat implied in many examples such as ?rrcov::maryo or Wilcox 2005) - the sample data should be (I presume univariate) normal (Crawley 2007) - the sample data can be of any distribution (if I understand correctly the `distribution-free' definition of correlation in Huber 1981, 2004) - the sample data could come from just about any bivariate distribution (Wikipedia [2][3] and associated reference) - the coefficient is (very) not robust to univariate outliers (e.g., Huber 1981), and to multivariate outliers (?rrcov::maryo with data from Marona and Yohai 1998) 2. Assessing whether the correlation is significantly different from zero (using a statistic following the t distribution): - the data should come
Re: [R] Problem accessing row number from subset on a dataframe
?which e.g.which(airquality$Month == 6) -- Bert Gunter Genentech Noclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jason Rupert Sent: Tuesday, May 26, 2009 1:55 PM To: Mark Wardle Cc: R-help@r-project.org Subject: Re: [R] Problem accessing row number from subset on a dataframe Mark, I really apprecaite your response and continue to be amazed by the responsiveness and support on the R forums. And, well actually, I would like to get the row number(s) and then delete or not via the row number. Again, I really appreciate the response... --- On Tue, 5/26/09, Mark Wardle m...@wardle.org wrote: From: Mark Wardle m...@wardle.org Subject: Re: [R] Problem accessing row number from subset on a dataframe To: Jason Rupert jasonkrup...@yahoo.com Cc: R-help@r-project.org Date: Tuesday, May 26, 2009, 3:18 PM Hi. I may be missing what you're trying to achieve, but... what about subset(airquality, airquality$Month!=6) instead? You can do arbitrarily complex queries if you wish, combining terms logically. You don't have to use the subset function. You may find it helpful to see what the following result in: airquality$Month==6 airquality[airquality$Month==6, ] airquality[airquality$Month==6, ] There are ways of getting the row numbers, but I suspect you don't actually need to do that, do you? Best wishes, Mark 2009/5/26 Jason Rupert jasonkrup...@yahoo.com: I would like to use the row number information returned from performing a subset command on a dataframe. For example, I would like to automatically delete some rows from a dataframe if they match a criteria. Here is my example below. data(airquality) names(airquality) subset(airquality, airquality$Month == 6) Now how do I delete the row numbers returned automatically? I know I can type airquality_mod-airquality[-c(32:60)] However, I would like to check the row information and then use it to delete the stuff out of the dataframe. Thank again for any feedback and insights. __ 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. -- Dr. Mark Wardle Specialist registrar, Neurology Cardiff, UK __ 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 accessing row number from subset on a dataframe
Ok, if you insist [although it's still unclear why you need this level of indirection!] Try ?which e.g. which(airquality$Month==5) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 which(airquality$Month==6) [1] 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 gives the vector indices. These can be used as row indices for the dataframe. bw Mark 2009/5/26 Jason Rupert jasonkrup...@yahoo.com: Mark, I really apprecaite your response and continue to be amazed by the responsiveness and support on the R forums. And, well actually, I would like to get the row number(s) and then delete or not via the row number. Again, I really appreciate the response... --- On Tue, 5/26/09, Mark Wardle m...@wardle.org wrote: From: Mark Wardle m...@wardle.org Subject: Re: [R] Problem accessing row number from subset on a dataframe To: Jason Rupert jasonkrup...@yahoo.com Cc: R-help@r-project.org Date: Tuesday, May 26, 2009, 3:18 PM Hi. I may be missing what you're trying to achieve, but... what about subset(airquality, airquality$Month!=6) instead? You can do arbitrarily complex queries if you wish, combining terms logically. You don't have to use the subset function. You may find it helpful to see what the following result in: airquality$Month==6 airquality[airquality$Month==6, ] airquality[airquality$Month==6, ] There are ways of getting the row numbers, but I suspect you don't actually need to do that, do you? Best wishes, Mark 2009/5/26 Jason Rupert jasonkrup...@yahoo.com: I would like to use the row number information returned from performing a subset command on a dataframe. For example, I would like to automatically delete some rows from a dataframe if they match a criteria. Here is my example below. data(airquality) names(airquality) subset(airquality, airquality$Month == 6) Now how do I delete the row numbers returned automatically? I know I can type airquality_mod-airquality[-c(32:60)] However, I would like to check the row information and then use it to delete the stuff out of the dataframe. Thank again for any feedback and insights. __ 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. -- Dr. Mark Wardle Specialist registrar, Neurology Cardiff, UK -- Dr. Mark Wardle Specialist registrar, Neurology Cardiff, UK __ 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 me...!!!
quoteFrom: Doran, Harold HDoran_at_air.org Date: Tue, 26 May 2009 14:26:53 -0400 The bad news, as others have indicated, is that this list is not for homework. The good news is that all of this is extremely easy in R!!! -Original Message- From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of abel1682 Sent: Tuesday, May 26, 2009 10:37 AM To: r-help_at_r-project.org Subject: [R] Help me...!!! Hi to all...i'm a new R'user and i have to solve some exercies so i ask to tou for an help... 1.) How i can demonstrate in R that the limit for x--infinite of (1+1/x)^x is equal to e? /quote Well, that's stretching the definition of demonstrate (to claim you can show this equality in R). IMHO you cannot show the value of an infinite sum in R, since that depends on theorems in calculus. You can show it's close but if I were the professor I'd not be happy with such a response. Students -- or the rest of us in GenPop -- who miss the difference there are just asking for disaster to strike. Carl __ 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 needed on R output
Thanks. I am sorry that I did not clearly put my question. I need to output the array like t - c( + , + 01001001011011101100, + 1001001011010101, + 1101110100000011, + 000100100101001001011001, + 000101101101101001101001) to a datafile(e.g., .txt file) where each line is for a binary number in this format: , 01001001011011101100, I was trying to use R-function write.table, however, I wasn't able to get the trailing comma for each line(although I can get the double quotation marks). Thanks. On Tue, May 26, 2009 at 12:46 AM, Linlin Yan yanlinli...@gmail.com wrote: t - c( + , + 01001001011011101100, + 1001001011010101, + 1101110100000011, + 000100100101001001011001, + 000101101101101001101001) { + cat ('rom_array := (\n'); + for (i in 1:length(t)) { + cat('', t[i], '', + ifelse(i == length(t), '', ',\n'), sep='') + }; + cat(')\n'); + } rom_array := ( , 01001001011011101100, 1001001011010101, 1101110100000011, 000100100101001001011001, 000101101101101001101001) On Tue, May 26, 2009 at 12:30 PM, peng chen rogerchan2...@gmail.com wrote: Hi, R experts: I am trying to generate data output in the following format: rom_array := ( , 01001001011011101100, 1001001011010101, 1101110100000011, 000100100101001001011001, 000101101101101001101001) I have all the necessary data line, however, I am having trouble generating the double quotation marks along with the trailing comma for each line. Anyone can help? Thanks. [[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. [[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] Using package exams and xtable
Hello, I am trying to use the package exams to construct problem sets. I have constructed an exercise which generates a list of integers and asks the student to compute the median. rx is the vector of n numbers str(rx) num [1:16] 21 9 8 18 4 12 17 2 9 7 ... I want to print out the entire vector as part of the problem. When I use \Sexpr(rx) only the first value (in this case 21) is printed out. I have been trying to get xtable to work. xtable(rx) Error in UseMethod(xtable) : no applicable method for xtable methods(xtable) [1] xtable.anova* xtable.aov* xtable.aovlist* [4] xtable.coxph* xtable.data.frame* xtable.glm* [7] xtable.lm* xtable.matrix* xtable.prcomp* [10] xtable.summary.aov* xtable.summary.aovlist* xtable.summary.glm* [13] xtable.summary.lm* xtable.summary.prcomp* xtable.table* [16] xtable.ts* xtable.zoo* Non-visible functions are asterisked I am new to R and would appreciate any suggestions. What is the best way to get exams/Sweave to print out the entire vector? Thanks in advance. DBerg [[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] Help needed on R output
If you want to create that output in a file, then create one long string and use 'cat' to output; here is an example with the output to the console: t - c( + , + 01001001011011101100, + 1001001011010101, + 1101110100000011, + 000100100101001001011001, + 000101101101101001101001) # create one long string and then use 'cat' to write it out long - paste('', paste(t, collapse=',\n'), '', sep='') cat(long) , 01001001011011101100, 1001001011010101, 1101110100000011, 000100100101001001011001, 000101101101101001101001 On Tue, May 26, 2009 at 9:33 AM, peng chen rogerchan2...@gmail.com wrote: Thanks. I am sorry that I did not clearly put my question. I need to output the array like t - c( + , + 01001001011011101100, + 1001001011010101, + 1101110100000011, + 000100100101001001011001, + 000101101101101001101001) to a datafile(e.g., .txt file) where each line is for a binary number in this format: , 01001001011011101100, I was trying to use R-function write.table, however, I wasn't able to get the trailing comma for each line(although I can get the double quotation marks). Thanks. On Tue, May 26, 2009 at 12:46 AM, Linlin Yan yanlinli...@gmail.com wrote: t - c( + , + 01001001011011101100, + 1001001011010101, + 1101110100000011, + 000100100101001001011001, + 000101101101101001101001) { + cat ('rom_array := (\n'); + for (i in 1:length(t)) { + cat('', t[i], '', + ifelse(i == length(t), '', ',\n'), sep='') + }; + cat(')\n'); + } rom_array := ( , 01001001011011101100, 1001001011010101, 1101110100000011, 000100100101001001011001, 000101101101101001101001) On Tue, May 26, 2009 at 12:30 PM, peng chen rogerchan2...@gmail.com wrote: Hi, R experts: I am trying to generate data output in the following format: rom_array := ( , 01001001011011101100, 1001001011010101, 1101110100000011, 000100100101001001011001, 000101101101101001101001) I have all the necessary data line, however, I am having trouble generating the double quotation marks along with the trailing comma for each line. Anyone can help? Thanks. [[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 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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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] Beta Testers Wanted for SPSS Statistics Developer
Since SPSS version 16 in 2007, we have had a free plug-in that allows R programs to run within SPSS, getting some or all of the active data and writing results to the SPSS Viewer as plain text or as SPSS pivot tables and R charts. This can require adding as few as two lines of code to the R program. With version 17, we added the ability easily to create SPSS-style dialog boxes. It is also possible to create SPSS-style syntax for R programs simply. With version 18, now called PASW Statistics, we have enhanced the plug-in, and we are introducing a new product, PASW Statistics Developer. This is a low-cost product without any statistics but including the framework and tools for integrating R and/or Python code as well as the standard data management and graphics. It enables the user to build their own set of statistical functions and smoothly integrate them into Developer. The beta test for Developer is starting soon. We are looking for people who know R but not necessarily PASW Statistics to test this product. If you are interested, please email Aaron Rangel, aran...@spss.com for details and to sign up. Thanks in advance for your interest. - Jon K Peck jkp...@gmail.com 312-651-3435 Now blogging at www.spss.com/insideout __ 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 with fractional seconds
Dear List, I am having problems converting a file with fractional seconds to class POSIXct. I have set my options to include digits.secs and my format to just time, but my output is the current date with my time lacking the fractions of a second. For example: options(digits.secs=3) t-c(06:00:00.100,06:00:01.231) myt-as.POSIXct(t,format=%H:%M:%S) myt [1] 2009-05-26 06:00:00 HST 2009-05-26 06:00:01 HST I would like the output to be just time with fractional seconds. I.e. 06:00:00.100,06:00:01.231 I have also tried Chron times() which did not work either. Interestingly, Sys.time() does produce fractional seconds, so I know the options are working. I would appreciate your help and suggestions. Aloha, Tim Tim Clark Department of Zoology University of Hawaii __ 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 with fractional seconds
Try this: as.POSIXct(c(06:00:00.100,06:00:01.231), format = %H:%M:%S%OS) [1] 2009-05-26 06:00:00.100 EDT 2009-05-26 06:00:00.231 EDT On Tue, May 26, 2009 at 5:52 PM, Tim Clark mudiver1...@yahoo.com wrote: Dear List, I am having problems converting a file with fractional seconds to class POSIXct. I have set my options to include digits.secs and my format to just time, but my output is the current date with my time lacking the fractions of a second. For example: options(digits.secs=3) t-c(06:00:00.100,06:00:01.231) myt-as.POSIXct(t,format=%H:%M:%S) myt [1] 2009-05-26 06:00:00 HST 2009-05-26 06:00:01 HST I would like the output to be just time with fractional seconds. I.e. 06:00:00.100,06:00:01.231 I have also tried Chron times() which did not work either. Interestingly, Sys.time() does produce fractional seconds, so I know the options are working. I would appreciate your help and suggestions. Aloha, Tim Tim Clark Department of Zoology University of Hawaii __ 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 multiple graphs based on one variable
Luc, Thanks! I was not aware of that package. It looks a lot easier than what I have been trying to do! Aloha, Tim Tim Clark Department of Zoology University of Hawaii --- On Tue, 5/26/09, Luc Villandre villa...@dms.umontreal.ca wrote: From: Luc Villandre villa...@dms.umontreal.ca Subject: Re: [R] Creating multiple graphs based on one variable To: Tim Clark mudiver1...@yahoo.com Cc: r-help@r-project.org Date: Tuesday, May 26, 2009, 4:01 AM Tim Clark wrote: Dear List, I would like to create several graphs of similar data. I have x and y values for several different individuals (in this case fish). I would like to plot the x and y values for each fish separately. I can do it using a for loop, but I think I should be using apply. Please let me know what I am doing wrong, or if there is a better way to do this. What I have is: #Test data dat-data.frame(c(rep(1:10,4)),c(rep(1:10,4)),c(rep(c(Tony,Mike,Vicky,Fred),each=10))) names(dat)-c(x,y,Name) #Create function to plot x and y myplot-function() plot(dat$x,dat$y) #Apply the function to each of the names par(mfcol=c(2,2)) apply(dat,2,myplot,by=dat$Name) #Does not work - tried various versions I would like separate plots for Tony, Mike, and Vicky. What is the best way to do this? Thank! Tim Tim Clark Department of Zoology University of Hawaii __ 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. Hi Tim, I'm now rather fond of Hadley Wickham's ggplot2 package. Its structure is most of the times intuitive and it does yield nice-looking output. In order to solve your problem, taking advantage of the ggplot2 framework, you can simply use the following: library(ggplot2) ; ## If you want all the curves to be on the same plotting grid ; p - ggplot(dat, aes(x=x,y=y, group=Name)) ; p + geom_line(aes(colour=Name)) ; ## Only one curve will be visible since they are all superposed. ## If you want the curves to be on separate plotting grids ; p - ggplot(dat, aes(x=x,y=y, group=Name)) ; p - p + geom_line(aes(colour=Name)) ; p+facet_grid(. ~ Name) ; Hope this helps, -- *Luc Villandré* /Biostatistician McGill University Health Center - Montreal Children's Hospital Research Institute/ __ 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 accessing row number from subset on a dataframe
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jason Rupert Sent: Tuesday, May 26, 2009 1:55 PM To: Mark Wardle Cc: R-help@r-project.org Subject: Re: [R] Problem accessing row number from subset on a dataframe Mark, I really apprecaite your response and continue to be amazed by the responsiveness and support on the R forums. And, well actually, I would like to get the row number(s) and then delete or not via the row number. Deleting by row number can lead to incorrect answers if you are not careful to dispose of the no-rows case specially, since when length(rowNumbers)==0, x[rowNumbers,] and x[-rowNumbers,] will return the same thing, the entire matrix or data.frame. If you use logical subscripts this is not a special case, you just use x[!rowSatisfiesCondition,] whether or not any row satisfies the condition. (Sometimes using integer instead of logical subscripts can save memory, but you need a pretty big problem to notice that.) d-data.frame(x=11:14,y=letters[11:14]) xIsFive - d$x==5 whichXIsFive - which(xIsFive) d[ !xIsFive, ] # correct x y 1 11 k 2 12 l 3 13 m 4 14 n d[ -whichXIsFive, ] # not what is wanted [1] x y 0 rows (or 0-length row.names) Again, I really appreciate the response... --- On Tue, 5/26/09, Mark Wardle m...@wardle.org wrote: From: Mark Wardle m...@wardle.org Subject: Re: [R] Problem accessing row number from subset on a dataframe To: Jason Rupert jasonkrup...@yahoo.com Cc: R-help@r-project.org Date: Tuesday, May 26, 2009, 3:18 PM Hi. I may be missing what you're trying to achieve, but... what about subset(airquality, airquality$Month!=6) instead? You can do arbitrarily complex queries if you wish, combining terms logically. You don't have to use the subset function. You may find it helpful to see what the following result in: airquality$Month==6 airquality[airquality$Month==6, ] airquality[airquality$Month==6, ] There are ways of getting the row numbers, but I suspect you don't actually need to do that, do you? Best wishes, Mark 2009/5/26 Jason Rupert jasonkrup...@yahoo.com: I would like to use the row number information returned from performing a subset command on a dataframe. For example, I would like to automatically delete some rows from a dataframe if they match a criteria. Here is my example below. data(airquality) names(airquality) subset(airquality, airquality$Month == 6) Now how do I delete the row numbers returned automatically? I know I can type airquality_mod-airquality[-c(32:60)] However, I would like to check the row information and then use it to delete the stuff out of the dataframe. Thank again for any feedback and insights. __ 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. -- Dr. Mark Wardle Specialist registrar, Neurology Cardiff, UK __ 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 multiple graphs based on one variable
Stefan, Thanks for the suggestion. Lattice works great. You might also want to check out the ggplot2 package that Luc suggested. They both seem to provide quite a few more options than the basic graphics package in R. Aloha, Tim Tim Clark Department of Zoology University of Hawaii --- On Mon, 5/25/09, Stefan Grosse singularit...@gmx.net wrote: From: Stefan Grosse singularit...@gmx.net Subject: Re: [R] Creating multiple graphs based on one variable To: Tim Clark mudiver1...@yahoo.com Cc: r-help@r-project.org Date: Monday, May 25, 2009, 11:55 PM On Tue, 26 May 2009 02:34:55 -0700 (PDT) Tim Clark mudiver1...@yahoo.com wrote: TC I would like separate plots for Tony, Mike, and Vicky. What is the TC best way to do this? use the lattice package: library(lattice) xyplot(y~x|Name,data=dat) Mr. Sarkar (the author of the package) has written an excellent book on his package I recommend it. hth Stefan __ 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 with fractional seconds
Gabor, Thanks, that worked. However, is there is way to just get the time and not have the date added? I assume the date is added since POSIX is based on seconds since 1970. I can't seem to convert the POSIX value to Chron times(), and Chron won't take fractional seconds. Are there other ways to deal with just time and not date? Thanks, Tim Tim Clark Department of Zoology University of Hawaii --- On Tue, 5/26/09, Gabor Grothendieck ggrothendi...@gmail.com wrote: From: Gabor Grothendieck ggrothendi...@gmail.com Subject: Re: [R] Problem with fractional seconds To: Tim Clark mudiver1...@yahoo.com Cc: r-help@r-project.org Date: Tuesday, May 26, 2009, 11:59 AM Try this: as.POSIXct(c(06:00:00.100,06:00:01.231), format = %H:%M:%S%OS) [1] 2009-05-26 06:00:00.100 EDT 2009-05-26 06:00:00.231 EDT On Tue, May 26, 2009 at 5:52 PM, Tim Clark mudiver1...@yahoo.com wrote: Dear List, I am having problems converting a file with fractional seconds to class POSIXct. I have set my options to include digits.secs and my format to just time, but my output is the current date with my time lacking the fractions of a second. For example: options(digits.secs=3) t-c(06:00:00.100,06:00:01.231) myt-as.POSIXct(t,format=%H:%M:%S) myt [1] 2009-05-26 06:00:00 HST 2009-05-26 06:00:01 HST I would like the output to be just time with fractional seconds. I.e. 06:00:00.100,06:00:01.231 I have also tried Chron times() which did not work either. Interestingly, Sys.time() does produce fractional seconds, so I know the options are working. I would appreciate your help and suggestions. Aloha, Tim Tim Clark Department of Zoology University of Hawaii __ 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] using lsoda() and nls() together
Hi Benoit, your problem is not really a problem of lsoda. The reason of the crash is a violation of the statistical assumptions of least squares regression due to dependency of residual variance on x. Due to this, K1 is varied over a very large range of values until numeric overflow occurs. Note that you have an exponentially growing state, so log transformation will help: res - nls(log(foo) ~ log(func(K1)),start=list(K1=1),data=data.frame(foo=y), trace=TRUE) summary(res) You may also consider using packages simecol (on CRAN) or FME (on R-Forge) that both support constrained optimization of ode systems. Hope it helps Thomas Petzoldt __ 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 with fractional seconds
Its in the second paragraph after the list of % codes. On Tue, May 26, 2009 at 6:11 PM, seeliger.c...@epamail.epa.gov wrote: Thanks for beating me to that, Gabor. The %OS format spec isn't in the strptime() docs. How else might we have found this for ourselves? cur r-help-boun...@r-project.org wrote on 05/26/2009 02:59:20 PM: as.POSIXct(c(06:00:00.100,06:00:01.231), format = %H:%M:%S%OS) [1] 2009-05-26 06:00:00.100 EDT 2009-05-26 06:00:00.231 EDT On Tue, May 26, 2009 at 5:52 PM, Tim Clark mudiver1...@yahoo.com wrote: ... options(digits.secs=3) t-c(06:00:00.100,06:00:01.231) myt-as.POSIXct(t,format=%H:%M:%S) myt [1] 2009-05-26 06:00:00 HST 2009-05-26 06:00:01 HST I would like the output to be just time with fractional seconds. I.e. 06:00:00.100,06:00:01.231 -- Curt Seeliger, Data Ranger Raytheon Information Services - Contractor to ORD seeliger.c...@epa.gov 541/754-4638 __ 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 with fractional seconds
Thanks for beating me to that, Gabor. The %OS format spec isn't in the strptime() docs. How else might we have found this for ourselves? cur r-help-boun...@r-project.org wrote on 05/26/2009 02:59:20 PM: as.POSIXct(c(06:00:00.100,06:00:01.231), format = %H:%M:%S%OS) [1] 2009-05-26 06:00:00.100 EDT 2009-05-26 06:00:00.231 EDT On Tue, May 26, 2009 at 5:52 PM, Tim Clark mudiver1...@yahoo.com wrote: ... options(digits.secs=3) t-c(06:00:00.100,06:00:01.231) myt-as.POSIXct(t,format=%H:%M:%S) myt [1] 2009-05-26 06:00:00 HST 2009-05-26 06:00:01 HST I would like the output to be just time with fractional seconds. I.e. 06:00:00.100,06:00:01.231 -- Curt Seeliger, Data Ranger Raytheon Information Services - Contractor to ORD seeliger.c...@epa.gov 541/754-4638 [[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] Problem with fractional seconds
Use format, format(myt, %H:%M:%S%OS) -- Curt Seeliger, Data Ranger Raytheon Information Services - Contractor to ORD seeliger.c...@epa.gov 541/754-4638 Thanks, that worked. However, is there is way to just get the time and not have the date added? I assume the date is added since POSIX is based on seconds since 1970. I can't seem to convert the POSIX value to Chron times(), and Chron won't take fractional seconds. Are there other ways to deal with just time and not date? [[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] Problem with fractional seconds
POSIXct is intended to represent date/times. You can use format to just show the times but the dates will still be there: format(Sys.time(), %H:%M:%S%OS) [1] 18:20:.910 difftime objects can represent times although perhaps not conveniently: now - Sys.time() now - as.POSIXct(cut(now, day)) Time difference of 18.35699 hours chron objects use the integer part as days and the fractional part as fractions of days so can represent whatever granularity you like up to machine precision although they won't print it out by default but its there as can be seen: now - Sys.time(); now [1] 2009-05-26 18:52:12.221 EDT tt - times(as.chron(now, tz = )) %% 1; tt [1] 18:52:12 # tt minus tt truncated to the sec still leaves subsecs as.numeric(tt - trunc(tt, 00:00:01)) * 24 * 60 * 60 [1] 0.220 On Tue, May 26, 2009 at 6:14 PM, Tim Clark mudiver1...@yahoo.com wrote: Gabor, Thanks, that worked. However, is there is way to just get the time and not have the date added? I assume the date is added since POSIX is based on seconds since 1970. I can't seem to convert the POSIX value to Chron times(), and Chron won't take fractional seconds. Are there other ways to deal with just time and not date? Thanks, Tim Tim Clark Department of Zoology University of Hawaii --- On Tue, 5/26/09, Gabor Grothendieck ggrothendi...@gmail.com wrote: From: Gabor Grothendieck ggrothendi...@gmail.com Subject: Re: [R] Problem with fractional seconds To: Tim Clark mudiver1...@yahoo.com Cc: r-help@r-project.org Date: Tuesday, May 26, 2009, 11:59 AM Try this: as.POSIXct(c(06:00:00.100,06:00:01.231), format = %H:%M:%S%OS) [1] 2009-05-26 06:00:00.100 EDT 2009-05-26 06:00:00.231 EDT On Tue, May 26, 2009 at 5:52 PM, Tim Clark mudiver1...@yahoo.com wrote: Dear List, I am having problems converting a file with fractional seconds to class POSIXct. I have set my options to include digits.secs and my format to just time, but my output is the current date with my time lacking the fractions of a second. For example: options(digits.secs=3) t-c(06:00:00.100,06:00:01.231) myt-as.POSIXct(t,format=%H:%M:%S) myt [1] 2009-05-26 06:00:00 HST 2009-05-26 06:00:01 HST I would like the output to be just time with fractional seconds. I.e. 06:00:00.100,06:00:01.231 I have also tried Chron times() which did not work either. Interestingly, Sys.time() does produce fractional seconds, so I know the options are working. I would appreciate your help and suggestions. Aloha, Tim Tim Clark Department of Zoology University of Hawaii __ 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] Finding and removing non-printable ascii characters in a file
Hi! I'm completely confusing myself attempting to solve this one. Is there a simple way of removing particular ASCII characters from a CSV file using R. Hopefully something simpler and faster than cycling through each individual character and comparing them to a list of characters to remove then deleting as necessary. As always, any help would be appreciated. Thanks! Dan [[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] Cgee: error: logistic model
Hello, Much like Charlie Wills a year ago, I am trying to run the APE program COMPAR.GEE with a model containing a categorical response variable and a continuous variable. My command code is : compar.gee(costusdata$Syndrome ~ costusdata$Stamen, phy = costustree, family = binomial) I receive the following output with an error: Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27 running glm to get initial regression estimate (Intercept) costusdata$Stamen18 costusdata$Stamen20.5 costusdata$Stamen22.5 costusdata$Stamen25.5 costusdata$Stamen27.5 costusdata$Stamen28 2.056607e+01 -3.750463e-08 -5.619142e-08 -5.644906e-08 -3.849581e-08 -5.622864e-08 -3.777595e-08 costusdata$Stamen30 costusdata$Stamen31 costusdata$Stamen32 costusdata$Stamen32.5 costusdata$Stamen35 costusdata$Stamen36.5 costusdata$Stamen37 -3.954765e-08 -3.749803e-08 -4.113214e +01 -1.917977e+01 -3.748004e-08 -4.113214e +01 -5.282325e-08 costusdata$Stamen37.5 costusdata$Stamen38.5 costusdata$Stamen39 costusdata$Stamen41.3 costusdata$Stamen42.5 costusdata$Stamen45 costusdata$Stamen47.5 -5.584079e-08 -4.113214e+01 -4.113214e +01 -5.272208e-08 -2.016060e+01 -4.113214e +01 -4.113214e+01 costusdata$Stamen50 costusdata$Stamen52.5 costusdata$Stamen55 costusdata$Stamen? -4.113214e+01 -4.113214e+01 -5.309908e-08 -2.264551e+01 Error in gee(costusdata$Syndrome ~ costusdata$Stamen, c(1, 1, 1, 1, 1, : Cgee: error: logistic model for probability has fitted value very close to 1. estimates diverging; iteration terminated. Simon Blumberg answered Charlie's issue with My guess is that this combination of variables produces separation in the data: Too many (all?) of the response 1's are in at level of VAR3, and the 0's are at the other level (or vice versa). I only have the two variables. I'm wondering if anyone has encountered this problem and how you went about solving it. I believe that the problem appears when one has to low (phylogenetic) replication within each (pollination mode) factor level. Is there a way to run compar.gee if this is in fact the problem. From the data, I want to know if there a decrease in the continuous trait is correlated with a change in the categorical trait. Any insight is much appreciated. Thank you, Jenn [[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] Finding and removing non-printable ascii characters in a file
You can use readLines to read the data in and then gsub to remove the characters you don't want and the textConnection to 'read' in the processed data. x - readLines(/tempxx.txt) # show data x [1] al;skdjf a;lskdjf s;aldkfj asd;lfkj_)(*)(**(^ *(^%*^% [3] a;lskdfj z,xmcvn -129037854 b qwepoiru 1234l;kjasdfmnb5 # now delete all numbers using regular expression (substitute your characters) # you can put any characters you want separated by '|' x.d - gsub(0|1|2|3|4|5|6|7|8|9, '', x) # reread using textConnection x.new - readLines(textConnection(x.d)) x.new [1] al;skdjf a;lskdjf s;aldkfj asd;lfkj _)(*)(**(^ *(^%*^% [3] a;lskdfj z,xmcvn - b qwepoiru l;kjasdfmnb On Tue, May 26, 2009 at 7:12 PM, Daniel Bradley dannyboy...@gmail.comwrote: Hi! I'm completely confusing myself attempting to solve this one. Is there a simple way of removing particular ASCII characters from a CSV file using R. Hopefully something simpler and faster than cycling through each individual character and comparing them to a list of characters to remove then deleting as necessary. As always, any help would be appreciated. Thanks! Dan [[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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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] Help needed on R output
Did you mean this: write.table(t, eol=,\n, row.names=FALSE, col.names=FALSE) , 01001001011011101100, 1001001011010101, 1101110100000011, 000100100101001001011001, 000101101101101001101001, Try ?write.table to get the detail of the function please. On Tue, May 26, 2009 at 9:33 PM, peng chen rogerchan2...@gmail.com wrote: Thanks. I am sorry that I did not clearly put my question. I need to output the array like t - c( + , + 01001001011011101100, + 1001001011010101, + 1101110100000011, + 000100100101001001011001, + 000101101101101001101001) to a datafile(e.g., .txt file) where each line is for a binary number in this format: , 01001001011011101100, I was trying to use R-function write.table, however, I wasn't able to get the trailing comma for each line(although I can get the double quotation marks). Thanks. __ 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] Beta Testers Wanted for SPSS Statistics Developer - email addresses
The email addresses in this message were obscured. If you are interested, please send email to arangel at spss dot com. Regards, Jon Peck jkpeck at gmail dot com. -- Forwarded message -- From: Jon Peck jkp...@gmail.com Date: May 26, 3:40 pm Subject: Beta Testers Wanted for SPSS Statistics Developer To: R-help-archive Since SPSS version 16 in 2007, we have had a free plug-in that allows R programs to run within SPSS, getting some or all of the active data and writing results to the SPSS Viewer as plain text or as SPSS pivot tables and R charts. This can require adding as few as two lines of code to the R program. With version 17, we added the ability easily to create SPSS-style dialog boxes. It is also possible to create SPSS-style syntax for R programs simply. With version 18, now called PASW Statistics, we have enhanced the plug-in, and we are introducing a new product, PASW Statistics Developer. This is a low-cost product without any statistics but including the framework and tools for integrating R and/or Python code as well as the standard data management and graphics. It enables the user to build their own set of statistical functions and smoothly integrate them into Developer. The beta test for Developer is starting soon. We are looking for people who know R but not necessarily PASW Statistics to test this product. If you are interested, please email Aaron Rangel, aran...@spss.com for details and to sign up. Thanks in advance for your interest. - Jon K Peck jkp...@gmail.com 312-651-3435 Now blogging atwww.spss.com/insideout __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://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] Newbie: Using R to analyse Apache logs
I saw a post (https://stat.ethz.ch/pipermail/r-help/2008-January/153086.html) where you stated you were using R to do some apache log analysis. I was about to embark on such a project . Is it posted anywhere (or could you drop it to me ?) I'm sure you are as busy as I am, if your code is open and you dont mind me looking at it , I would greatly appreciate it , if nothing else give me a good starting point for using R. thankyou doug twyman __ 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] Exception from HRESULT: 0x80040013
Hallo Everyone, I have a problem getting R DCom to work on a MS Server 2003. I am using Visual Studio 2005 to use some statistical functions from R. I have installed DCOM 1.3.5. but as soon as the statement iR.Init(R) is executed I get the following error: Exception from HRESULT: 0x80040013 I know this code means installation problem: unable to load connector,But I do not know how to resolve. I have checked the path and the environmental variables and there are none associated with the RDCom, which is what I would expect. I searched the registry for differences between my computer where it works but have not found anything useful I have also tried to install Version R 2.9.0 from But this did not resolve the prblem Any ideas? Thanks... __ 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] Harmonic Analysis
I am looking for a package to perform harmonic analysis with the goal of estimating the period of the dominant high frequency component in some mono-channel signals. I guess there are presumably a number of CRAN packages allowing for such analysis. However, my search with keywords was not successfull. It brought up a lot of Fourier miscellanea but nothing specifically geared for my needs. I would greatly appreciate your suggestions. Thank you in advance. Maura tutti i telefonini TIM! [[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.