Re: [R] Dataverse (reading files with .tab and .7z suffixes)
Ilio Fornasero writes: > Yet, I am at this point. > > > > > ## 01. Finding the dataverse server and making a search > Sys.setenv("DATAVERSE_SERVER" =3D "dataverse.harvard.edu") > dataverse_search(".Hunger") > > > ## 02. Loading the dataset (in this example, I have chosen the word ".Hunge= > r" to get ># one list and then picked up one out of hundreds results. ># The get-dataset() function has to be picked on the dynamic web address= > ) > (dataset_ifpri <- get_dataset("https://doi.org/10.7910/DVN/ZTCWYQ;)) > > ## 03. Grabbing the (1st) file we are interested on > AppendixC <- get_file("001_AppendixC.tab", > "https://doi.org/10.7910/DVN/ZTCWYQ;) > writeBin(AppendixC, "001_AppendixC.tab") > > read.table("001_AppendixC.tab") I imagine you are using the dataverse package. 7z is more straightforward because the file format is clear. You need to figure out the 001_AppendixC.tab file format. On first glance it looks to me like a spreadsheet. $ file /tmp/001_AppendixC.tab /tmp/001_AppendixC.tab: Zip archive data, at least v2.0 to extract $ cd /tmp && unzip 001_AppendixC.tab $ head -n2 /tmp/xl/workbook.xml | cut -c 1-75 http://schemas.openxmlformats.org/spreadsheetml/2006/main; Once you figure out the format manually, write an R function that figures out the format, and ask again here to find an R function that reads the format. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Dataverse (reading files with .tab and .7z suffixes)
Ilio Fornasero writes: > I am trying to find a way to retrieve data from Harvard Dataverse website. > I usually don't have problem in web-scraping data but the problem here is > that there are a bunch of data formats such as .tab, .7z and so and > I just can't find a way to retrieve the data I am interested in woth an > unique solution. > Any hint? .tab does not identify a file format. That file might be in a read.csv format or a read.fwf format. No 7z decompressor seems to exist in CRAN, (I checked `findFn('7z')`.) so you could use system/system2: `system2('7z', c('e', ...)), or I think 7z.exe on Windows. You would need to install p7zip and read the manual (`man 7z` on a Unix-like system). Please send an example. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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-help Digest, Vol 183, Issue 13
Ilio Fornasero writes: > Hello. > > I am trying to find a way to retrieve data from Harvard Dataverse website. > I usually don't have problem in web-scraping data but the problem here is > that there are a bunch of data formats such as .tab, .7z and so and I just > can't find a way to retrieve the data I am interested in woth an unique > solution. > Any hint? .tab does not identify a file format. It might be in a read.csv format or a read.fwf format. No 7z decompressor seems to exist in CRAN, (I checked `findFn('7z')`.) so you could use system/system2: `system2('7z', c('e', ...)), or I think 7z.exe on Windows. You would need to install p7zip and read the manual (`man 7z` on a Unix-like system). Please send an example. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] [FORGED] Rotating points, preferably in grid
Well this is great. Now I have answers for both graphics and grid. The rot argument is exactly what I had wanted, except that I had imagined it also working on points. But I had not thought to use unicode, and that will probably make this plot even easier. Thanks __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Rotating points, preferably in grid
I want to make a plot in polar coordinates. I want to use pch with shapes that do not have radial symmetry, so I want to rotate them such that they face inwards. I am using grid for my plotting, but I provide motivating examples in graphics. The following plot almost gets me what I want. theta <- 2*pi*seq(0,7/8,1/8) plot(cos(theta), sin(theta), pch=2, axes=F, asp=1) But I want the points to face inwards. I can do something like this with text, but I can set only a constant rotation plot.new() plot.window(c(-1,1),c(-1,1), asp=1) text(cos(theta), sin(theta), 'Tom', srt =runif(1,0,360)) To rotate all of the points, I can do something like this. plot.new() plot.window(c(-1,1),c(-1,1), asp=1) for (the.theta in theta) text(cos(the.theta), sin(the.theta), 'Tom', srt=(360/(2*pi))*(the.theta-(1/4)*2*pi)) So perhaps I could use a "T" instead of a numeric pch and consequently do something like this. plot.new() plot.window(c(-1,1),c(-1,1), asp=1) for (the.theta in theta) text(cos(the.theta), sin(the.theta), 'T', srt=(360/(2*pi))*(the.theta+(1/4)*2*pi)) But that seems a bit silly. Is there a more declarative way of doing this, preferably in grid? Thanks __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Making my own graphics device
Thanks for the further tips! I'll look at the R Internals manual, the other built-in devices, and the RSvgDevice package. And I'm still looking for the S source code, but I have a feeling that I'll wind up writing the device before I find the source code. It may be useful to look at existing interfaces to an HPGL device in other graphics applications. One such application is xgraph and here is the C code for one implementation: http://xgraph.sourcearchive.com/documentation/12.1-3/hpgl_8c-source.html The other option might be to enlist an external program such as GNUPLOT that has an HPGL output and use it as a driver to which you send an image in a file format that R can produce. While this would be a good idea for pretty much any other file format, it probably will make things more complicated for HPGL as the structure of base R graphics is kind of exactly the same as HPGL. Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Making my own graphics device
I want to make my own graphics device am thus looking for documentation about graphics devices. The only thing I've found so far is these directions for making graphics devices with the RGraphicsDevice package. http://www.omegahat.org/RGraphicsDevice/ Could someone point me to any other resources? Or just some documentation about how to edit base R? If I don't get anything, I'm just going to stare at the grDevices section of the R source code (src/library/grDevices/src) until I figure out how it works. In case you're curious, I want to make a graphics device that saves the graph in Hewlett-Packard Graphics Language. https://en.wikipedia.org/wiki/HPGL Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Making my own graphics device
Thanks for this! I had a feeling that was the case; the R graphics functions are so clearly designed for use with pen plotters that I was puzzled by the absense of an HPGL device. And now I've found a list of some other interesting devices on page 71 of Modern Applied Statistics with S. This Wikipedia article says that S source code was released in 1981. (I never knew!) https://en.wikipedia.org/wiki/S_%28programming_language%29 So I'm going to look for publications related to S from 1981. Say something if you have any tips for my search. On 17 Aug 15:11, Roger Koenker wrote: In ancient times, ie circa 1981, the S language certainly supported HP pen plotters so there should be code somewhere that could be resuscitated, he said naively. url:www.econ.uiuc.edu/~rogerRoger Koenker emailrkoen...@uiuc.eduDepartment of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Urbana, IL 61801 On Aug 17, 2014, at 2:58 PM, Thomas Levine _...@thomaslevine.com wrote: I want to make my own graphics device am thus looking for documentation about graphics devices. The only thing I've found so far is these directions for making graphics devices with the RGraphicsDevice package. http://www.omegahat.org/RGraphicsDevice/ Could someone point me to any other resources? Or just some documentation about how to edit base R? If I don't get anything, I'm just going to stare at the grDevices section of the R source code (src/library/grDevices/src) until I figure out how it works. In case you're curious, I want to make a graphics device that saves the graph in Hewlett-Packard Graphics Language. https://en.wikipedia.org/wiki/HPGL Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] HPGL or PCL plotting device? Or otherwise plotting plots
Hi, I want to print plots on a Roland DXY-1100 plotter. How can I do this from R? I think the easiest thing would be a graphics device for Printer Command Language or Hewlett-Packard Graphics Language, but I haven't managed to find any of those. Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] HPGL or PCL plotting device? Or otherwise plotting plots
Oh it was easier than I thought. postscript('project-contracts.ps') hist(log(projects$n.contracts)) dev.off() Then run this from the shell. pstoedit -f plot-hpgl project-contracts.ps project-contracts.hpgl And send it to the plotter. On 09 Jul 13:10, Thomas Levine wrote: Hi, I want to print plots on a Roland DXY-1100 plotter. How can I do this from R? I think the easiest thing would be a graphics device for Printer Command Language or Hewlett-Packard Graphics Language, but I haven't managed to find any of those. Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] HPGL or PCL plotting device? Or otherwise plotting plots
Actually, this doesn't _quite_ do what I want; I want different R colors (1, 2, 3, c.) to select different pens in HPGL (SP1, SP2, SP3, c.), but the HPGL file I get selects only pen 1. A hacky way to do this would be to generate a few different postscript files for the different colors on the plot, create the corresponding HPGL files, edit the SP command in each of them, and concatenate them. But maybe there's a better way? On 09 Jul 13:32, Thomas Levine wrote: Oh it was easier than I thought. postscript('project-contracts.ps') hist(log(projects$n.contracts)) dev.off() Then run this from the shell. pstoedit -f plot-hpgl project-contracts.ps project-contracts.hpgl And send it to the plotter. On 09 Jul 13:10, Thomas Levine wrote: Hi, I want to print plots on a Roland DXY-1100 plotter. How can I do this from R? I think the easiest thing would be a graphics device for Printer Command Language or Hewlett-Packard Graphics Language, but I haven't managed to find any of those. Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Stripchart colors don't vary after I sort a data frame
# Hi, # This plot has two colors. overflow - read.csv('http://chainsaw.thomaslevine.com/overflow.csv', stringsAsFactors = F) png('original.png') stripchart(overflow$precipi ~ overflow$after.9.am, method='stack', pch = 22, bg = overflow$overflow + 1, vertical = T, col = 0) dev.off() # I wanted continuous bands of color, so I sorted the data frame. # But after sorting, it only had one color. overflow.sorted - overflow[order(overflow$overflow),] png('sorted.png') stripchart(overflow.sorted$precipi ~ overflow.sorted$after.9.am, method='stack', pch = 22, bg = overflow.sorted$overflow + 1, vertical = T, col = 0) dev.off() # What's wrong? # Here are all of the files. # http://chainsaw.thomaslevine.com/overflow.csv # http://chainsaw.thomaslevine.com/original.png # http://chainsaw.thomaslevine.com/sorted.png # Thanks # Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Can I specify POSIX[cl]t column classes inside read.csv?
I'm loading a nicely formatted csv file. #!/usr/bin/env Rscript kpi - read.csv( # This is a dump of the username, date_joined and last_login columns # from the auth_user Django table. 'data/2012-04-23.csv', colClasses = c('character') ) print(kpi[sample(nrow(kpi), 3),2:3]) Here's what the three rows I printed look like. last_login date_joined 2012-02-22 02:44:11 2011-09-19 03:07:35 2011-09-16 01:34:41 2011-09-16 01:34:41 2011-07-02 20:29:17 2011-07-02 20:29:17 Once I load them, I'm converting the datetimes to datetimes. kpi$last_login - as.POSIXlt(kpi$last_login) kpi$date_joined - as.POSIXlt(kpi$date_joined) Can I do this inside of read.csv by specifying colClasses? It's obviously not a problem if I can't; it just seems like I should be able to. Note that the following doesn't work because it doesn't save the times. colClasses = c('character', 'Date', 'Date') Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 development master class: NYC, Dec 12-13
Hmm... you know I'd love to run a study on how software and other information displays affect the speed, accuracy and reliability with which people make insights about data. Tom On Tue, Nov 15, 2011 at 4:44 PM, Stavros Macrakis macra...@alum.mit.eduwrote: Last time, I was told that I couldn't list my R package and associated papers as a research activity with substantial impact because it was outside my official scope of work. (Even though I wrote it so I could *do* my work.) That seems wrong. My impression is that method papers were frequent citation classics http://garfield.library.upenn.edu/classics.html. Why should a software method paper be treated worse than a (e.g.) chemical method paper? -s On Sun, Nov 13, 2011 at 15:58, Sarah Goslee sarah.gos...@gmail.com wrote: On Sun, Nov 13, 2011 at 2:55 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Some of the money I earn from these courses goes to pay for my summer salary and supports student research. It also gives me confidence that if I don't get tenure because I've been writing R packages instead of papers, I can keep doing the work I love. If that actually happens, that would be an amazing/colossal (not in a good way) testament to how well the rating system works in academia. I'm not in academia, but government research. I do go through a review very similar to the tenure process. Last time, I was told that I couldn't list my R package and associated papers as a research activity with substantial impact because it was outside my official scope of work. (Even though I wrote it so I could *do* my work.) I have no trouble seeing academic administrators do the same thing. Sarah -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] squared pie chart - is there such a thing?
How about just a stacked bar plot? barplot(matrix(c(3,5,3),3,1),horiz=T,beside=F) Tom On Fri, Jul 22, 2011 at 7:14 AM, Naomi Robbins nbrgra...@optonline.net wrote: Hello! It's a shoot in the dark, but I'll try. If one has a total of 100 (e.g., %), and three components of the total, e.g., mytotal=data.frame(x=50,y=30,z=20), - one could build a pie chart with 3 sectors representing x, y, and z according to their proportions in the total. I am wondering if it's possible to build something very similar, but not on a circle but in a square - such that the total area of the square is the sum of the components and the components (x, y, and z) are represented on a square as shapes with right angles (squares, rectangles, L-shapes, etc.). I realize there are many possible positions and shapes - even for 3 components. But I don't really care where components are located within the square - as long as they are there. Is there a package that could do something like that? Thanks a lot! - I included waffle charts in Creating More Effective Graphs. The reaction was very negative; many readers let me know that they didn't like them. To create them I just drew a table in Word with 10 rows and 10 columns. Then I shaded the backgrounds of cells so for your example we would shade 50 cells one color, 30 another, and 20 a third color. Naomi - Naomi B. Robbins 11 Christine Court Wayne, NJ 07470 973-694-6009 na...@nbr-graphs.com mailto:na...@nbr-graphs.com http://www.nbr-graphs.com Author of Creating More Effective Graphs http://www.nbr-graphs.com/bookframe.html // [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] computer name
Not exactly R, but how about pcname - system('uname -n',intern=T) Tom On Sun, Jun 12, 2011 at 11:19 PM, pdb ph...@philbrierley.com wrote: Is there an r function that will be able to identify the computer the code is running on? I have some common code that I run on several computers and each has a database with a different server name - although the content is identical. I need to set thisServer depending on which machine the code is running on... something like... if(pcname = pc1) thisServer = 'SERVER1' if(pcname = pc2) thisServer = 'SERVER2' conn - odbcDriverConnect(driver=SQL Server;database=x;server=thisServer;) ...rest of code will now run OK. I know I could set the DSN names the same and use... conn - odbcConnect(commonDSNname) but I was wondering if there was another way -- View this message in context: http://r.789695.n4.nabble.com/computer-name-tp3593120p3593120.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] Odp: Three sigma rule
I think you really want a normality test. If that's what you want, you have more options than the three-sigma rule. http://en.wikipedia.org/wiki/Normality_test Tom On Tue, May 31, 2011 at 12:31 PM, Bert Gunter gunter.ber...@gene.com wrote: Folks: On Tue, May 31, 2011 at 8:48 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi r-help-boun...@r-project.org napsal dne 28.05.2011 20:12:33: Salil Sharma sali...@gmail.com Odeslal: r-help-boun...@r-project.org Dear Sir, I have data, coming from tests, consisting of 300 values. Is there a way in R with which I can confirm this data to 68-95-99.8 rule or three-sigma rule? I need to look around percentile ranks and prediction intervals for this data. I, however, used SixSigma package and used ss.ci() function, which produced 95% confidence intervals. I still am not certain about percentile ranks conforming to 68-95-99.7 rule for this data. Not sure what you exactly want but you could look at function quantile. -- Nor am I, but ... Or you could compute confidence interval for mean by e.g. I'm pretty sure that this is NOT what he wants. -- Bert mean.int function (x, p = 0.95) { x.na - na.omit(x) mu - mean(x.na) odch - sd(x.na) l - length(x.na) alfa - (1 - p)/2 mu.d - mu - qt(1 - alfa, l - 1) * odch/sqrt(l) mu.h - mu + qt(1 - alfa, l - 1) * odch/sqrt(l) return(data.frame(mu.d, mu, mu.h)) } Regards Petr Thanks and regards, Salil Sharma [[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. -- Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions. -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with barplot
You can do pretty well without ggplot actually. boxplot(Time~paste(Incidents,Months),data=DF,border=c('grey20','red')) On Sat, May 28, 2011 at 2:55 AM, steven mosher mosherste...@gmail.com wrote: Thanks, ggplot is on my list of things to learn before Hadley comes here to the bay area to give a session on interactive graphics in R On Fri, May 27, 2011 at 10:29 PM, Joshua Wiley jwiley.ps...@gmail.comwrote: Hi Steven, This is not, strictly speaking, the answer to your question (hopefully Tom already answered that). Rather, it is the answer to questions you *might* have asked (and perhaps one of them will be one you wished you had asked). Barplots have a low data:ink ratio...you are using an entire plot to convey 8 means. A variety of alternatives exist. As a minimal first step, you could just use points to show the means and skip all the wasted bar space, and you might add error bars in (A). You could also use boxplots to give your viewers (or just yourself) a sense of the distribution along with the medians (B). Another elegant option is violin plots. These are kind of like (exactly like?) mirrored density plots. A measure of central tendency is not explicitly shown, but the *entire* distribution and range is shown (C). Cheers, Josh (P.S. I hit send too soon before and sent you an offlist message with PDF examples) ## Create your data DF - data.frame( Incidents = factor(rep(c(a, b, d, e), each = 25)), Months = factor(rep(1:2, each = 10)), Time = rnorm(100)) ## Load required packages require(ggplot2) require(Hmisc) ## Option A ggplot(DF, aes(x = Incidents, y = Time, colour = Months)) + stat_summary(fun.y = mean, geom = point, position = position_dodge(width = .90), size = 3) + stat_summary(fun.data = mean_cl_normal, geom = errorbar, position = dodge) ## Option B ggplot(DF, aes(x = Incidents, y = Time, fill = Months)) + geom_boxplot(position = position_dodge(width = .8)) ## Option C ggplot(DF, aes(x = Time, fill = Months)) + geom_ribbon(aes(ymax = ..density.., ymin = -..density..), alpha = .2, stat = density) + facet_grid( ~ Incidents) + coord_flip() ## Option C altered ggplot(DF, aes(x = Time, fill = Months)) + geom_ribbon(aes(ymax = ..density.., ymin = -..density..), alpha = .2, stat = density) + facet_grid( ~ Incidents + Months) + scale_y_continuous(name = density, breaks = NA, labels = NA) + coord_flip() On Fri, May 27, 2011 at 3:08 PM, steven mosher mosherste...@gmail.com wrote: Hi, I'm really struggling with barplot I have a data.frame with 3 columns. The first column represents an incident type The second column represents a month The third column represents a time Code for a sample data.frame incidents - rep(c('a','b','d','e'), each =25) months - rep(c(1,2), each =10) times -rnorm(100) # make my sample data DF - data.frame(Incidents=as.factor(incidents),Months=as.factor(months),Time=times) # now calculate a mean for the by groups of incident type and month pivot - aggregate(DF$Time,by=list(Incidents=DF$Incidents,Months=DF$Month),FUN=mean,simplify=TRUE) What I want to create is a bar plot where I have groupings by incident type ( a,b,d,e) and within each group I have the months in order. So group 1 would be Type a; month 1,2; group 2 would be Type b; month 1,2; group 3 would be Type d; month 1,2; group 4 would be Type 3; month 1,2; I know barplot is probably the right function but I'm a bit lost on how to specify groupings etc TIA [[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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with barplot
Does this do it? barplot(t(matrix(pivot$x,4)),beside=T) Tom On Fri, May 27, 2011 at 6:08 PM, steven mosher mosherste...@gmail.com wrote: Hi, I'm really struggling with barplot I have a data.frame with 3 columns. The first column represents an incident type The second column represents a month The third column represents a time Code for a sample data.frame incidents - rep(c('a','b','d','e'), each =25) months - rep(c(1,2), each =10) times -rnorm(100) # make my sample data DF - data.frame(Incidents=as.factor(incidents),Months=as.factor(months),Time=times) # now calculate a mean for the by groups of incident type and month pivot - aggregate(DF$Time,by=list(Incidents=DF$Incidents,Months=DF$Month),FUN=mean,simplify=TRUE) What I want to create is a bar plot where I have groupings by incident type ( a,b,d,e) and within each group I have the months in order. So group 1 would be Type a; month 1,2; group 2 would be Type b; month 1,2; group 3 would be Type d; month 1,2; group 4 would be Type 3; month 1,2; I know barplot is probably the right function but I'm a bit lost on how to specify groupings etc TIA [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Null
Maybe you were doing something like fcv - read.csv('fcv.csv') instead of fcv - read.csv('fcv.csv')[1] (I haven't tested this.) Tom On Thu, May 5, 2011 at 8:48 AM, pcc polly...@hotmail.com wrote: This is probably a very simple question but I am completely stumped!I am trying to do shapiro.wilk(x) test on a relatively small dataset(75) and each time my variable and keeps coming out as 'NULL', and shapiro.test(fcv) Error in complete.cases(x) : no input has determined the number of cases my text file looks like this: case 1.600972896 1.534026106 1.633468456 1.69019608 1.686636269 1.713490543 1.460897843 1.604226053 1.547774705 1.575187845 1.50242712 1.489958479 1.555094449 1.56937391 1.46686762 1.583198774 1.59439255 1.627365857 1.596597096 1.598790507 1.596597096 1.613841822 1.607455023 1.586587305 1.72427587 1.668385917 1.743509765 1.5774918 1.709269961 1.507855872 1.650307523 1.670245853 1.721810615 1.613841822 1.586587305 1.658011397 1.595496222 1.662757832 1.521138084 1.564666064 1.515873844 1.596597096 1.617000341 1.621176282 1.598790507 1.73479983 1.498310554 1.571708832 1.426511261 1.698970004 1.534026106 1.5774918 1.682145076 1.689308859 1.654176542 1.526339277 1.545307116 1.658964843 1.638489257 1.557507202 1.604226053 1.627365857 1.651278014 1.627365857 1.559906625 1.720159303 1.64738297 1.62324929 1.698970004 1.704150517 1.57863921 1.558708571 1.681241237 1.539076099 1.5132176 Any ideas? -- View this message in context: http://r.789695.n4.nabble.com/Null-tp3498261p3498261.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] Generalized Linear Model
Because you have two dependent variables, you'll want to to use a multivariate logit. mlogit does this, but I don't know the syntax off hand. If you just wanted to look at one dependent variable, it would be the following (which Alex said) glm(y~x1*x2,family='binomial') On Mon, Apr 25, 2011 at 3:28 PM, Megan aforkonapl...@hotmail.com wrote: Hello, I am trying to run a generalized linear model but do not know where to begin. I have attached my data to R but do not know where to go from there. I have two independent variables (each has two factors associated with them) and two dependent variables, each with either a yes/no response which I've valued either 0 or 1 in the data set. Any input would be greatly appreciated. -- View this message in context: http://r.789695.n4.nabble.com/Generalized-Linear-Model-tp3473924p3473924.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] How to erase (replace) certain elements in the data.frame?
This should do the same thing random.del - function (x, n.keeprows, del.percent){ del-function(col){ col[sample.int(length(col),length(col)*del.percent/100)]-NA col } change-n.keeprows:nrow(x) x[change,]-lapply(x[change,],del) x } This is faster because it's vectorized. [1] Mine user system elapsed 0.004 0.000 0.002 [1] Yours user system elapsed 1.172 0.020 1.193 Tom On Sat, Apr 23, 2011 at 8:37 PM, sneaffer sneaf...@mail.ru wrote: Hello R-world, Please, help me to get round my little mess I have a data.frame in which I'd rather like some values to be NA for the future imputation process. I've come up with the following piece of code: random.del - function (x, n.keeprows, del.percent){ n.items - ncol(x) k - n.items*(del.percent/100) x.del - x for (i in (n.keeprows+1):nrow(x)){ j - sample(1:n.items, k) x.del[i,j] - NA } return (x.del) } The problems is that random.del turns out to be slow on huge samples. Is there any other more effective/charming way to do the same? Thanks, Sergey -- View this message in context: http://r.789695.n4.nabble.com/How-to-erase-replace-certain-elements-in-the-data-frame-tp3470883p3470883.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] How to erase (replace) certain elements in the data.frame?
As Joshua said, mine was indeed different from yours. And it didn't work on non-numeric data. But this one seems to work right: random.del_vec - function (x, n.keeprows, del.percent){ del-function(notkeep){ k-floor(length(notkeep)*del.percent/100) notkeep[sample.int(length(notkeep),k)]-NA notkeep } change-(n.keeprows+1):nrow(x) x[change,]-t(apply(x[change,],1,del)) x } On the other hand, maybe you really didn't want the stratification by row. Tom On Sun, Apr 24, 2011 at 8:31 AM, sneaffer sneaf...@mail.ru wrote: Thanks a lot, guys. Thomas, your method is great, precisely the thing I've been looking forward to. Oh dear, how I love R for those list comprehension tricks! -- View this message in context: http://r.789695.n4.nabble.com/How-to-erase-replace-certain-elements-in-the-data-frame-tp3470883p3471380.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] Sample size estimation for sample surveys
Hi, Is there an R package for estimating sample size requirements for parameter estimation in sample surveys? In particular, I'm interested in sample size estimation for stratified and systematic sampling. I have a textbook with appropriate formulae, but it'd be nice if I didn't have to type in all of the equations. Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 estimation for sample surveys
Awesome! Thanks, David and Dennis! And now I know how to search for packages more effectively. Tom On Mon, Apr 4, 2011 at 9:38 PM, Dennis Murphy djmu...@gmail.com wrote: Start here: library(sos) # install first if necessary findFn('sample size survey') I got 238 hits, many of which could be relevant. HTH, Dennis On Mon, Apr 4, 2011 at 6:05 PM, Thomas Levine thomas.lev...@gmail.com wrote: Hi, Is there an R package for estimating sample size requirements for parameter estimation in sample surveys? In particular, I'm interested in sample size estimation for stratified and systematic sampling. I have a textbook with appropriate formulae, but it'd be nice if I didn't have to type in all of the equations. Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Two matrix loop
This way uses a three-dimensional array instead of the nested apply. It seems to take the same amount of time, even on larger datasets, but it may give you ideas. distance=function(x) daisy(x, metric = 'gower') persons=array(dim=c(2,nrow(donor)*nrow(receiver),ncol(receiver))) persons[1,,]=donor[rep(1:nrow(donor),each=nrow(receiver)),] persons[2,,]=receiver[rep(1:nrow(receiver),nrow(donor)),] matrix(apply(persons,2,distance),,nrow(donor)) Tom On Thu, Mar 24, 2011 at 8:23 AM, Stefan Petersson stefan.peters...@inizio.se wrote: Hi, I'm trying to create a distance matrix. And it works out somewhat ok. However, I suspect that there are some efficiency issues with my efforts. Plz have a look at this: donor - matrix(c(3,1,2,3,3,1,4,3,5,1,3,2), ncol=4) receiver - matrix(c(1,4,3,2,4,3,1,5,1,3,2,1,4,5,3,5,1,3,2,4,5,1,2,3,1,4,5,5,1,2,1,3,4,3,2,5,5,1,4,2,5,4,3,2), ncol=4) The above creates my two matrices. I have three donors, and eleven receivers (rows), with four measures (columns) in each matrix. And now, I want to apply the daisy() function from the cluster library, to calculate distances between my three donors, and eleven receivers. The end result should be a 11x3 matrix with distances between the units from the two matrices. I can calculate one distance measure (ie donor 1 and receiver 1). Like this: library(cluster) daisy(rbind(donor[1,], receiver[1,]), metric = 'gower') My first attempt was a simple nested for-loop. But that one was discarded after reading up on efficiency issues with for-looping. So I turned to 'apply' with this result: apply(donor, 1, function(b) apply(receiver, 1, function(a) daisy(rbind(b, a), metric = 'gower'))) [,1] [,2] [,3] [1,] 1.00 0.50 0.75 [2,] 1.00 0.75 0.75 [3,] 0.75 1.00 1.00 [4,] 0.50 0.75 0.75 [5,] 0.75 1.00 0.75 [6,] 0.75 1.00 0.50 [7,] 0.75 0.50 0.75 [8,] 1.00 1.00 1.00 [9,] 1.00 0.75 1.00 [10,] 0.75 0.50 1.00 [11,] 0.75 1.00 0.25 However, something tells me that there is a simpler (more efficient) way of doing this. I've been reading up on the Matrix library, but I'm having trouble understanding the functions... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] simple if question
Posting some sample data would help, but I think something like this is what you want data[data$school=='Cornell University',] For example CO2[CO2$Type=='Quebec',] Tom 2011/3/26 Sebastián Daza sebastian.d...@gmail.com: Hi everyone, I have just got different samples from a dataframe (independent and exclusive, there aren't common elements among them). I want to create a variable that indicate the sampling selection of the elements in the original dataframe (for example, 0 = no selected, 1= sample 1, 2=sample 2, etc.). I have tried to do it with ifelse command, but the problem is that the second line replaces the values of the first line, and I haven't been able to do it with the if command (I got this error: In if (data$school %in% sample1) { : the condition has length 1 and only the first element will be used) data$selection - ifelse(data$school %in% sample1, 1, 0) data$selection - ifelse(data$school %in% sample2, 2, 0) Any ideas? Thank you in advance. -- Sebastián Daza sebastian.d...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Extracting columns from a class
Hi, Here is the prcomp output. tom=prcomp(matrix(rnorm(25),5,5)) R functions often output lists. To see what's in this one, run names(tom) or type tom$ and use tab completion. Once you do that, the following is more obvious. pc1=tom$rotation[,1] sd1=tom$sdev[1] column=c(sd1,pc1) write.table(column,tom,row.names=F,col.names=F) This will send the column to the file tom. Tom On Thu, Mar 17, 2011 at 8:10 AM, nuncio m nunci...@gmail.com wrote: Hi list, I am not a frequent user of R. Recently I used R in principal component analysis and got the result as a class, which has information like standard deviation and principal components from 1 to 10. How is it possible to extract the column corresponding to first principal component and write it to a file the out from prcomp command is something like this Standard deviations: [1] 3.325801e+00 7.669837e-01 6.625773e-01 4.990732e-01 3.470071e-01 [6] 2.946679e-01 2.206289e-01 1.645828e-01 1.570887e-01 4.741294e-16 Rotation: PC1 PC2 PC3 PC4 PC5 [1,] -0.07900624 -0.0824864352 0.1208419434 0.1763425845 0.089545020 [2,] -0.09114708 -0.0901675110 0.1377608881 0.2224127252 0.076620976 [3,] -0.10510742 -0.0935434206 0.1113586044 0.2513993555 0.029783117 I want to extract PC1 and 1 value in the standard deviation Thanks -- Nuncio.M Research Scientist National Center for Antarctic and Ocean research Head land Sada Vasco da Gamma Goa-403804 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Easy help with plots, font size
There's also pointsize, depending on your device. On Thu, Feb 3, 2011 at 9:31 PM, gigi1234 ggra...@gmail.com wrote: Ok thanks. I did have some success using the cex options. Figured out that I was putting some of the arguments in the wrong place. Thanks again! On Thu, Feb 3, 2011 at 8:24 PM, David Winsemius [via R] ml-node+3259390-1216185916-210...@n4.nabble.comml-node%2b3259390-1216185916-210...@n4.nabble.com ml-node%2b3259390-1216185916-210...@n4.nabble.comml-node%252b3259390-1216185916-210...@n4.nabble.com wrote: On Feb 3, 2011, at 7:12 PM, gigi1234 wrote: I am trying to make some plots for a poster. Each one needs to be 6 inches by inches. Right now the fonts are too small and the plots don't read well on my poster. I am pretty much an R newbie and I can't figure out how to change the fonts. It would also be nice to know how to specify the size of the plot and maybe how to save the plots as jpeg files. Any help would be much appreciated! I am not too picky about the details like font type, I just want the size of the fonts (especially the axes and axes labels) to be bigger! ?par cex, cex.main, cex.lab, and cex.axis are arguments that should be helpful to control various font sizes. ?Devices ?jpeg The device settings are where you can change the plot size. There are examples on the help pages. Thanks so much! Here is my code: # Poster figure 1 stationmean=c(19.4833,10.8000) fieldmean=c(14.6852, 15.5981) plot(c(0,1),fieldmean,xaxt='n',type=b,pch=20,col=green3, main=Foxtail Seeds Remaining vs.Field Type, ylab=Mean Number Foxtail Seeds Remaining, xlab=Field Type,ylim=c(10,20),xlim=c(-.25,1.25)) axis(1,at=c(0,1),labels=c(Cover Crop,Wheat Stubble)) # Poster figure 2 stationmean=c(19.4833,10.8000) fieldmean=c(14.6852, 15.5981) plot(c(0,1),stationmean,xaxt='n',type=b,pch=20,col=green3, main=Foxtail Seeds Remaining vs. Station Type, ylab=Mean Number Foxtail Seeds Remaining, xlab=Station Type,ylim=c(10,20),xlim=c(-.25,1.25)) axis(1,at=c(0,1),labels=c(Invertebrate Only,Open Access)) # Poster figure 3 meantime=22.1 meancumrainfall=.4837 meanavelowt=35.4920071 meanavehight=55.3242738 meanvegcover=81.1729167 pred.veg = 33.3160 + -.2439*meantime - .8409*(.5) + 8.6833*(.5) + .5427*(meancumrainfall)-.3087*(meanavehight) + .01087*(seq(0,164.5,by=5)) pred.veg plot(seq(0,164.5,by=5),pred.veg,type='l',col='blue',lwd=2, main='Foxtail Seeds Remaining vs. Vegetative Cover Biomass', xlab='Vegetative Cover Biomass (g / 0.25 m^2', ylab='Mean Number Foxtail Seeds Remaining',ylim=c(10,22)) # Poster figure 4 meantime=22.1 meancumrainfall=.4837 meanavelowt=35.4920071 meanavehight=55.3242738 meanvegcover=81.1729167 pred.rain = 33.3160 + -0.2439*meantime - .8409*(.5) + 8.6833*(.5) - 1.0571*(seq(0,1.569,by=.1))-.3087*(meanavehight) + .01087*(meanvegcover) pred.rain plot(seq(0,1.569,by=.1),pred.rain,type='l',col='blue',lwd=2, main='Foxtail Seeds Remaining vs. Cumulative Rainfall', xlab='Cumulative Rainfall (in)', ylab='Mean Number Foxtail Seeds Remaining',ylim=c(10,22)) # Poster figure 5 meantime=22.1 meancumrainfall=.4837 meanavelowt=35.4920071 meanavehight=55.3242738 meanvegcover=81.1729167 pred.high = 33.3160 + -.2439*meantime - .8409*(.5) + 8.6833*(.5) + 1.0571*(meancumrainfall)-.3087*(seq(37.733,74.38228571,by=1)) + .01087*(meanvegcover) pred.high plot(seq(37.733,74.38228571,by=1),pred.high,type='l',col='blue',lwd=2, main='Foxtail Seeds Remaining vs. Average Daily High Temp', xlab='Average Daily High Temperature (degrees F)', ylab='Mean Number Foxtail Seeds Remaining',ylim=c(10,22)) # Poster figure 6 meantime=25.333 meancumrainfall=.4015 meanavelowt=37.9325 meanavehight=62.2579683 meanvegcover=77.6145833 meannumtotseedwt=.8708333 pred.seed = 24.4096 + -.1930*meantime - 3.5233*(.5) + 11.8611*(.5) - 2.7335*(meancumrainfall)-.1510*(meanavehight) + .01286*(meanvegcover) - 3.2848*(seq(.2,1.6,by=.05)) pred.seed plot(seq(.2,1.6,by=.05),pred.seed,type='l',col='blue',lwd=2, main='Foxtail Seeds Remaining vs. Ambient Seed Load', xlab='Ambient Seed Load (g / 0.25 m^2', ylab='Mean Number Foxtail Seeds Remaining',ylim=c(8,16)) -- View this message in context: http://r.789695.n4.nabble.com/Easy-help-with-plots-font-size-tp3259270p3259270.html http://r.789695.n4.nabble.com/Easy-help-with-plots-font-size-tp3259270p3259270.html?by-user=t Sent from the R help mailing list archive at Nabble.com. __ [hidden email] http://user/SendEmail.jtp?type=nodenode=3259390i=0mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
[R] Converting numbers into words
Example data desk=data.frame( deskchoice=c('mid','mid','left','bookdrop','mid','bookdrop') ) -- I like doing stuff like the line below, especially when I'm using Sweave. print(paste('Within the observation period,',nrow(desk), 'patrons approached the circulation desk.')) -- But what if I want to put it at the beginning of a sentence? print(sum(desk$deskchoice=='bookdrop'),'persons', 'used the book drop. Everyone else interacted with a staff member.') Is there a pretty way to change the result of sum(desk$deskchoice=='bookdrop') from 2 to Two? -- And what if the number is one? print(sum(desk$deskchoice=='bookdrop'), c('person','persons')[as.numeric(sum(desk$deskchoice=='bookdrop')!=1)+1], 'used the book drop. Everyone else interacted with a staff member.') Is there a prettier way of choosing between person and persons? -- Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 script on linux?
Open a terminal, then run these two commands. cd /home/the/directory/with/your/script R Then run this in R source('yourscript.R') Tom 2010/11/2 Jonathan P Daily jda...@usgs.gov: What is the error message? -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 Is the room still a room when its empty? Does the room, the thing itself have purpose? Or do we, what's the word... imbue it. - Jubal Early, Firefly From: gokhanocakoglu ocako...@uludag.edu.tr To: r-help@r-project.org Date: 11/02/2010 09:11 AM Subject: Re: [R] R script on linux? Sent by: r-help-boun...@r-project.org I can't run the script the program doesn't work... -- View this message in context: http://r.789695.n4.nabble.com/R-script-on-linux-tp3023650p3023670.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] make many barplot into one plot
hierobarp or barNest from {plotrix} may do this more neatly. 2010/10/31 Sibylle Stöckli sibylle.stoec...@gmx.ch Dear R users I would like to group my barplot graph (see example on the R help link). The proposed R code, adding individual bars to the plot, looks really overwhelming. My specific dataset just consists of five groups and three different levels within each groups (the individual bars). The .txt file is read as matrix (horizontal: group, vertical: levels). The R trellis barchart (function group=) is an easy function, but unfortunately the upper plot part look much different from other graphs. I would therefore prefer barplot to stansdardize my plots within the manuscript. It would be very helpful for me to know if anyone else has worked on the barplot group function. Thanks Sibylle http://onertipaday.blogspot.com/2007/05/make-many-barplot-into-one-plot.html R code from the link ## I have 4 tables like this:satu - array(c(5,15,20,68,29,54,84,119), dim=c(2,4), dimnames=list(c(Negative, Positive), c(Black, Brown, Red, Blond)))dua - array(c(50,105,30,8,29,25,84,9), dim=c(2,4), dimnames=list(c(Negative, Positive), c(Black, Brown, Red, Blond)))tiga - array(c(9,16,26,68,12,4,84,12), dim=c(2,4), dimnames=list(c(Negative, Positive), c(Black, Brown, Red, Blond)))empat - array(c(25,13,50,78,19,34,84,101), dim=c(2,4), dimnames=list(c(Negative, Positive), c(Black, Brown, Red, Blond)))# rbind() the tables togetherTAB - rbind(satu, dua, tiga, empat)# Do the barplot and save the bar midpointsmp - barplot(TAB, beside = TRUE, axisnames = FALSE)# Add the individual bar labelsmtext(1, at = mp, text = c(N, P),line = 0, cex = 0.5)# Get the midpoints of each sequential pair of bars# within each of the four groupsat - t(sapply(seq(1, nrow(TAB), by = 2),function(x) colMeans(mp[c(x, x+1), ])))# Add the group labels ! for each pairmtext(1, at = at, text = rep(c(satu, dua, tiga, empat), 4),line = 1, cex = 0.75)# Add the color labels for each groupmtext(1, at = colMeans(mp), text = c(Black, Brown, Red, Blond), line = 2) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] times
I couldn't figure that out, but you can work around it by adding the seconds chron(dates=lwc.file[,1],times=paste(lwc.file[,2],':00',sep='')) Tom 2010/10/28 thoeb t.hoebin...@gmail.com: Hi! I have an input table with a column Dates in the format month/day/year (eg. 5/11/1999 and a column Times in the format hours/minutes (eg. 15:20). In R I need to convert them into chron objects to extract colums only containing months, days, minutes, .. For the dates it is no problem if I write: dmy.lwc-chron(dates=lwc.file[,1],format=(dates=m/d/y)) But it does not work the same way for the times if I write: hm.lwc-chron(times=lwc.file[,2],format=(times=h:m)) Error-Message: Error in convert.times(times., fmt) : format h:m may be incorrect In addition: Warning message: In is.na(out$s) : is.na() applied to non-(list or vector) of type 'NULL' Why should the format h:m not be correct? -- View this message in context: http://r.789695.n4.nabble.com/times-tp3016621p3016621.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] R and Matlab
Is there a particular reason you can't use csv? write.csv() in R It seems that you can read csv in Matlab with this http://www.mathworks.com/help/techdoc/ref/importdata.html Tom 2010/10/28 Claudia Beleites cbelei...@units.it: I am looking for ways to use R and Matlab. Doing the data transformations in R and using the data in Matlab to analyze with some pre-defined scripts. Any good ways to transfer the data into matlab in its most recent version? I tried using R.matlab but the writeMat output is not readable by Matlab. It used to work, but I didn't need it for quite a while (a year or so ago, and with Matlab either 2007 or 2008a). I just tried, and neither does it work for me. You should notify the maintainer of R.matlab and include an example (code and data, e.g. with dput). I noticed that library (R.matlab) does not load the Rcompression package, but also after library (Rcompression), the resulting file was not read by Matlab. I tried loading a saved data.frame in Matlab 2008b on an Win XP computer: it doesn't find any variables inside the .mat file (and whos -file ...) doesn't show a variable. The other way round with a stupid little vector it worked. An R session (with only the 2nd try, after library (Rcompression)) is attached below. I just need to output a data.frame and read it as is into matlab where I can do any needed transformations on the variables. If you need to transfer the data right NOW, there's always csv. Claudia library (hyperSpec) Loading required package: lattice Package hyperSpec, version 0.95 To get started, try vignette (introduction, package = hyperSpec) package?hyperSpec vignette (package = hyperSpec) If you use this package please cite it appropriately. citation(hyperSpec) will give you the correct reference. The project is hosted on http://r-forge.r-project.org/projects/hyperspec/ sessionInfo () R version 2.12.0 (2010-10-15) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C LC_TIME=en_US.utf8 [4] LC_COLLATE=en_US.utf8 LC_MONETARY=C LC_MESSAGES=en_US.utf8 [7] LC_PAPER=en_US.utf8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] hyperSpec_0.95 lattice_0.19-13 R.matlab_1.3.3 R.oo_1.7.4 R.methodsS3_1.2.1 loaded via a namespace (and not attached): [1] grid_2.12.0 library (Rcompression) x = flu[[]] writeMat (flu.mat, flu) Error in dim(x) - length(x) : invalid first argument writeMat (flu.mat, x) sessionInfo () R version 2.12.0 (2010-10-15) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C LC_TIME=en_US.utf8 [4] LC_COLLATE=en_US.utf8 LC_MONETARY=C LC_MESSAGES=en_US.utf8 [7] LC_PAPER=en_US.utf8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Rcompression_0.8-0 hyperSpec_0.95 lattice_0.19-13 R.matlab_1.3.3 R.oo_1.7.4 [6] R.methodsS3_1.2.1 loaded via a namespace (and not attached): [1] grid_2.12.0 -- Claudia Beleites Dipartimento dei Materiali e delle Risorse Naturali Università degli Studi di Trieste Via Alfonso Valerio 6/a I-34127 Trieste phone: +39 0 40 5 58-37 68 email: cbelei...@units.it __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] lineplot.CI {sciplot}: continuous line
It could be more elegant, but I think this does what you want. ... lineplot.CI(blck, perf, group = cnd, xlab=Block, ylab=% Optimal Responses, cex.leg=1.2, x.leg = 18, y.leg=0.4, err.width=0.05, pch = c(15,15), col=c(grey, black), lty=c(1,1), main = Experiments 2 and 3, ylim=c(0.3,1), fixed=TRUE, ci.fun= function(x) c(mean(x)-1.96*se(x), mean(x)+1.96*se(x)),leg.lab=c(cond2, cond3)) y=by(perf,list(cnd,blck),mean) lines(1:20,y[1,1:20],col='grey') lines(1:29,y[2,1:29],col='black') Tom 2010/10/27 Fotis Fotiadis fotisfotia...@yahoo.gr: Sorry for that, I was trying to keep my question short. lineplot.CI(blck, perf, group = cnd, xlab=Block, ylab=% Optimal Responses, cex.leg=1.2, x.leg = 18, y.leg=0.4, err.width=0.05, pch = c(15,15), col=c(grey, black), lty=c(1,1), main = Experiments 2 and 3, ylim=c(0.3,1), fixed=TRUE, ci.fun= function(x) c(mean(x)-1.96*se(x), mean(x)+1.96*se(x)),leg.lab=c(cond2, cond3)) Thanks, Fotis --- Στις Τετ., 27/10/10, ο/η Thomas Levine thomas.lev...@gmail.com έγραψε: Από: Thomas Levine thomas.lev...@gmail.com Θέμα: Re: [R] lineplot.CI {sciplot}: continuous line Προς: Fotis Fotiadis fotisfotia...@yahoo.gr Κοιν.: r-help@r-project.org Ημερομηνία: Τετάρτη, 27 Οκτώβριος 2010, 19:47 Sending your code would help. All I can say now is that I have a hunch that you should consider a different type of plot. Tom 2010/10/27 Fotis Fotiadis fotisfotia...@yahoo.gr: Hallo to all I am trying to plot the learning curves of two groups of participants using the lineplot.CI() function. Since there are 30 levels on my x-axix, the resulting curves is kind of fragmented and not really continuous. Is there a way to minimize the gap between the mean points and the connecting lines? Thank you in advance, Fotis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Y Axis Labels
Oops. That was backwards plot(scale~time,axes=F) axis(2,at=0:4,labels=c(Never, Once per month, A few times per month, A few times per week,Everyday)) axis(1) Tom 2010/10/27 Thomas Levine thomas.lev...@gmail.com: More specifically time=rnorm(20)+10 scale=rep(0:4,4) plot(time~scale,axes=F) axis(1,at=0:4,labels=c(Never, Once per month, A few times per month, A few times per week,Everyday)) axis(2) Tom 2010/10/27 Sarah Goslee sarah.gos...@gmail.com: You can use axis() to draw custom axes of many sorts. The examples under ?axis demonstrate how to not draw the default axes and how to make custom ones. Sarah On Wed, Oct 27, 2010 at 10:40 AM, Downey, Patrick pdow...@urban.org wrote: Hello, I have am plotting a 0-4 ordinal scale (y-axis) against time (x-axis). Is there a way to label the values on the y-axis with the translation from the scale? That is, instead of having 0,1,2,3,4 on the y-axis, I would like Never, Once per month, A few times per month, A few times per week, Everyday. Thanks, Mitch -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Changing origin of line in radial plot
I guess you have something like this. testlen - c(sin(seq(0,1.98*pi,length=100))+2+rnorm(100)/10) testpos - seq(0,1.98*pi,length=100) radial.plot(testlen,testpos,rp.type=p,main=Test Polygon,line.col=blue) (http://addictedtor.free.fr/graphiques/graphcode.php?graph=75) Does this work? radial.plot(5-testlen,testpos,rp.type=p,main=Test Polygon,line.col=blue,radial.lim=c(0,5),radial.labels=5:0) Tom 2010/10/27 Gonzalo Garcia-Perate gonzill...@gmail.com: I am creating radial plots to visualise popularity of a series of topics, I was wondering if someone has come across a radial plot in which the lines originate from the edge of the plot instead of the centre, does anyone know how can this be achieved in R? Are there any good reasons not to do it? Thanks, Gonzalo -- Gonzalo Garcia-Perate PhD candidate, Bartlett School of Architecture, Building, Environmental Design Planning. University College London. Gower Street, London WC1E 6BT g.garcia-per...@ucl.ac.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] Multiple, multiple regressions...
Write a function() that does everything you want to do for one regression, then run that on all of them. It'll look something like this. library(car) myreg=function(X,v1,v2,v3,v4,v5) { reg=lm(X ~ v1 + v2 + v3 + v4 + v5) crPlots(reg) } Then run the function a lot, maybe in a loop or with sapply(). Tom 2010/10/26 Duncan, Adam adam.dun...@credit-suisse.com: Caveats and disclaimers: I am quite happy to undertake self-teaching if directed to a relevant prior posting and welcome such direction. I have programming and statistical training/experience which I would characterize as Masters level. Thank you for reading and replying to this post. It is very much appreciated. ---begin problem description I have a large data set that I have imported to R from excel via the RODBC library. The data set contains information about 4 factors for 22 currency pairs per factor. That is, the first 22 columns are, say, the spot exchange rate. The next 22 columns are, say, the interest rate differential, and so on. There is a singular vector in the data set at the end bringing the total number of columns to 89. The objective is to run a multiple regression of the form: X ~ v1 + v3 + v3 + v4 + v5 and display a plot of the residuals. The tough part is that I need to run this multiple regression 22 times, once for each currency pair. I would like to produce a graphic that contains, say, the first 8 residual plots on one page. Ultimately, I would like to produce standardized residuals for each regression, and rank them in order of the absolute value of the most recent residual. I have created matrix variables to house each of the 22 currency variables. Here is a result of examining the matrix variable idiff that holds the interest rate differentials: head(idiffm,5) EURINTDIF GBPINTDIF JPYINTDIF CHFINTDIF CADINTDIF AUDINTDIF NZDINTDIF SEKINTDIF NOKINTDIF EURJPYINTDIF EURGBPINTDIF 1 -0.02562 -0.16125 0.47000 0.56542 -0.23625 3.64625 2.57875 0.16875 -1.82625 0.44438 0.13563 2 -0.01125 -0.13813 0.45188 0.54521 -0.25979 3.68062 2.60312 0.13688 -1.88812 0.44063 0.12688 3 0.01313 -0.11875 0.42875 0.51667 -0.28583 3.70500 2.62750 0.11750 -1.91750 0.44188 0.13188 4 0.01313 -0.11875 0.42875 0.51667 -0.28583 3.70500 2.62750 0.11750 -1.91750 0.44188 0.13188 5 0.01313 -0.11875 0.42875 0.51667 -0.28583 3.70500 2.62750 0.11750 -1.91750 0.44188 0.13188 EURCHFINTDIF EURCADINTDIF EURAUDINTDIF EURNZDINTDIF EURSEKINTDIF EURNOKINTDIF NOKSEKINTDIF CADJPYINTDIF AUDJPYINTDIF 1 0.53980 1.5 -3.67187 -2.60437 0.14313 -1.85187 1.995 0.70625 4.11625 2 0.53396 1.50167 -3.69187 -2.61437 0.12563 -1.89937 2.025 0.71167 4.13250 3 0.52980 1.49833 -3.69187 -2.61437 0.13063 -1.90437 2.035 0.71458 4.13375 4 0.52980 1.49833 -3.69187 -2.61437 0.13063 -1.90437 2.035 0.71458 4.13375 5 0.52980 1.49833 -3.69187 -2.61437 0.13063 -1.90437 2.035 0.71458 4.13375 GBPJPYINTDIF NZDJPYINTDIF 1 0.30875 3.04875 2 0.31375 3.05500 3 0.31000 3.05625 4 0.31000 3.05625 5 0.31000 3.05625 ---end problem description Can someone point me to a script that might be useful in running all 22 of these multiple regressions and plotting the residuals (or at least the first 8-10) in a singular graphic? Thank you very much for the help. Best regards, -adam duncan adam.dun...@credit-suisse.com === Please access the attached hyperlink for an important el...{{dropped:4}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Embedding graphics in a pdf()
I've had two reasons for wanting to embed graphics in R pdf output. 1. I am plotting something on top of a surface (It's actually a desk.) of which I have a picture and would like to place a picture underneath. 2. I can produce all of my presentation slides in R without LaTeX but have a few pictures that I need to include as slides. I would like to add images inside the R script instead of manipulating them afterwards with Imagemagick and pdftk. Can these be done? Tom [[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] Embedding graphics in a pdf()
Woah! That's so awesome! And now I've found even more functions of my drawing programs that can be replaced with R. Tom 2010/7/14 Marc Schwartz marc_schwa...@me.com On Jul 14, 2010, at 1:38 PM, Thomas Levine wrote: I've had two reasons for wanting to embed graphics in R pdf output. 1. I am plotting something on top of a surface (It's actually a desk.) of which I have a picture and would like to place a picture underneath. 2. I can produce all of my presentation slides in R without LaTeX but have a few pictures that I need to include as slides. I would like to add images inside the R script instead of manipulating them afterwards with Imagemagick and pdftk. Can these be done? Tom See this reply (from Sunday) by David Winsemius on a similar query: https://stat.ethz.ch/pipermail/r-help/2010-July/245291.html HTH, Marc Schwartz [[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] Passing a LaTeX length to Sweave
I'd really love to do this \setkeys{Gin}{width=\columnwidth} label=something,fig=TRUE,echo=FALSE,width=\columnwidth,height=0.3\columnwidth= plot(y~x) @ The \columnwidth macro does not work, of course, in the second line. What can I do instead? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Passing a LaTeX length to Sweave
Darn. Well here's what I'll do %Preamble lengths= columnwidth=whatever the \columnwidth is @ %Figures \setkeys{Gin}{width=\columnwidth} label=something,fig=TRUE,echo=FALSE,width=columnwidth,height=0.3*columnwidth= plot(y~x) @ It needs to be exact so that the line weight and point size are consistent across figures and with the text. 2010/7/10 Duncan Murdoch murdoch.dun...@gmail.com: On 10/07/2010 10:35 AM, Thomas Levine wrote: I'd really love to do this \setkeys{Gin}{width=\columnwidth} label=something,fig=TRUE,echo=FALSE,width=\columnwidth,height=0.3\columnwidth= plot(y~x) @ The \columnwidth macro does not work, of course, in the second line. What can I do instead? Pass a number. As long as it's reasonably close to the truth the graphs will be resized and things will be fine. 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SAS for R-users
Thanks for the suggestions! This will keep me busy for a while. Tom 2010/5/15 Muenchen, Robert A (Bob) muenc...@utk.edu: Thomas Levine wrote: Bob Muenchen says that 'Ralph O’Brien says that in a few years there will be so many students graduating knowing mainly R that [he]’ll need to write, “SAS for R Users.” That’ll be the day!' Heh! I quite agree. I've had a few people write me saying they had used my book R for SAS and SPSS Users to learn SAS, but I certainly didn't aim for that when writing it. For R programmers wanting to learn SAS, here's what I recommend: 1. Read the text of the free version of R for SAS and SPSS Users at http://r4stats.com. That version has extremely short explanations of the differences by topic. Most of the explanation about R is in the form of comments in the R programs, which you can skip of course. The SAS programs will give you an idea of the basics. The book version adds lots of explanation but it's all about R, so skip that. 2. Read The Little SAS Book http://www.amazon.com/Little-SAS-Book-Primer-Third/dp/1590473337/ref=sr_1_1?ie=UTF8s=booksqid=1273963558sr=8-1 This is a quick and easy read that covers the basics well. 3. Read SAS and R http://www.amazon.com/SAS-Management-Statistical-Analysis-Graphics/dp/1420070576/ref=sr_1_1?ie=UTF8s=booksqid=1273963594sr=1-1 SAS and R is a good book that covers both SAS and R. The explanations are very brief but well written. That brevity allows it to cover a lot of ground. 4. For in-depth topics, the SAS documentation is well written and all online: http://support.sas.com/documentation/index.html Although the SAS manuals are online, knowing what to look up is the challenge for an R user. That's where 1 and 3 will help. Get ready for a whole different kind of world! Cheers, Bob = Bob Muenchen (pronounced Min'-chen), Manager Research Computing Support Voice: (865) 974-5230 Email: muenc...@utk.edu Web: http://oit.utk.edu/research, News: http://oit.utk.edu/research/news.php Feedback: http://oit.utk.edu/feedback/ = __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SAS for R-users
There are loads of resources for users of any other statistics package who are learning R. For example http://www.google.com/search?q=r+for+sas-users; The reverse isn't the case http://www.google.com/search?q=sas+for+r-users; Having heard rumors of how unelegant other statistics packages are, I don't see why any R-user would ever want to switch to anything else. That said, users of other statistics packages will sometimes make R-users switch to their statistics packages. The only resources I've found for R-users learning SAS are still intended for SAS-users learning R. http://sas-and-r.blogspot.com http://sites.google.com/site/r4statistics/the-books/r4sas-spss Bob Muenchen says that 'Ralph O’Brien says that in a few years there will be so many students graduating knowing mainly R that [he]’ll need to write, “SAS for R Users.” That’ll be the day!' I can't wait that long. Until then and until I can convince colleagues and teachers to use better software, how do you suggest that I learn SAS? I suspect that it'll be a book on R for SAS-users, so I'm expecting recommendations of books like those that are best for R-users learning SAS. This question would be more appropriate for a SAS mailing list, I couldn't find any except for those of a few regional groups. Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fwd: nonlinearity and interaction
Creating the 5 indicator variables will be easy if you post your code and sample data. This may also allow people to help with the first problem you were having. Tom 2010/5/14 William Simpson william.a.simp...@gmail.com: [posted this at 9:25 and still hasn't appeared on the list at 13:26] I have the following set-up. 6 values of a continuous variable (let's say light intensity) are presented to a system. The input is presented as a random series of blocks lasting (say) 5 sec each. etc time - The output is measured and sampled at say 10 samples/sec. Please ignore the fact that this is a time series and don't suggest things like ar() and arima(). I have looked at the autocorrelation function of the output and it is an amazing spike at a lag of zero and zilch elsewhere. Call the input x and the output y. I can find the relationship between x and y by fit-lm(y~x) coef(fit) tells me the line that best fits x vs y (as shown in the plot of the 6 values of x vs the mean values of y at those values). Question: Suppose that the system is nonlinear such that the response to the sequence 0,2 is not the same as the response to 2, 0 -- it is not just a change of the response by the same amount. Or nonlinear in other weird ways (I don't just mean simple things like y~x^2). I am thinking that a way to characterise this might be to pretend that x is not a continuous variable and to represent it with 5 indicator variables. And then interactions between them would tell me about nonlinear effects? e.g. lm(y~ d1 + d2 + d3 + d4 + d5 + d1*d2) etc Does this make any sense? If so, please suggest a good way to go about this; how to set up the dummy variables and how to interpret the results. Ideally, the same lm() fit would tell me about the linear effect y~x and the nonlinearities. Both sorts of effect will co-exist. Thanks very much for any help! Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fitting a function
x-c(0.5,4,6,8,12) y-c(0.021,0.021,0.020,0.018,0.012) lm(y~x) 2010/5/14 Dani Valverde daniel.valve...@uab.cat: Hello, It is a very naive question, but here it is. I have this values: x: 0.5 4 6 8 12 y: 0.021 0.021 0.020 0.018 0.012 I need to fit a function to them. How can I do it with R? Thank you so much! Dani -- Daniel Valverde Saubí Grup de Biologia Molecular de Llevats Facultat de Veterinària de la Universitat Autònoma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vallès- SPAIN Tlf. +34 93 581 1910 Fax: +34 93 581 1573 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fitting a function
I spoke too soon; that is not linear. I've never used the model-fitting functions, but you may check them out. http://developer.r-project.org/model-fitting-functions.txt Tom 2010/5/14 Thomas Levine thomas.lev...@gmail.com: x-c(0.5,4,6,8,12) y-c(0.021,0.021,0.020,0.018,0.012) lm(y~x) 2010/5/14 Dani Valverde daniel.valve...@uab.cat: Hello, It is a very naive question, but here it is. I have this values: x: 0.5 4 6 8 12 y: 0.021 0.021 0.020 0.018 0.012 I need to fit a function to them. How can I do it with R? Thank you so much! Dani -- Daniel Valverde Saubí Grup de Biologia Molecular de Llevats Facultat de Veterinària de la Universitat Autònoma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vallès- SPAIN Tlf. +34 93 581 1910 Fax: +34 93 581 1573 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fitting a function
Actually, ignore my comment about that link. I don't think that link is what you want to look at either. y~x^2 fits quite well, but you could also write a loop to run lm() on a bunch of different transformations. foo=list(log,sqrt) for (bar in foo) { plot(bar(x),y) } There may be a function that does this already, but I couldn't find it either. Sorry for sending so many emails 2010/5/14 Thomas Levine thomas.lev...@gmail.com: I spoke too soon; that is not linear. I've never used the model-fitting functions, but you may check them out. http://developer.r-project.org/model-fitting-functions.txt Tom 2010/5/14 Thomas Levine thomas.lev...@gmail.com: x-c(0.5,4,6,8,12) y-c(0.021,0.021,0.020,0.018,0.012) lm(y~x) 2010/5/14 Dani Valverde daniel.valve...@uab.cat: Hello, It is a very naive question, but here it is. I have this values: x: 0.5 4 6 8 12 y: 0.021 0.021 0.020 0.018 0.012 I need to fit a function to them. How can I do it with R? Thank you so much! Dani -- Daniel Valverde Saubí Grup de Biologia Molecular de Llevats Facultat de Veterinària de la Universitat Autònoma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vallès- SPAIN Tlf. +34 93 581 1910 Fax: +34 93 581 1573 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Bar plots with bars made of stacked text
I would like to make bar plots where the bars are composed of text like this: http://www.thomaslevine.com/lowres/text_bars.png Is there a package that will help me with this? Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Change the scale on a barplot's y axis
I have grades data. I read them from a csv in letter-grade format. I then converted them to levels levels(grades$grade)=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-') And then to numbers grades$gp=grades$grade levels(grades$gp)=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7) grades$gp=as.numeric(as.character(grades$gp)) And I'm plotting them in a barplot barplot(gp[order(gp)],width=n[order(gp)],ylab=Class Median Grade,xlab=Class, scaled to number of students in the class,main=Class Median Grades for Cornell University weighted by class size) I would like to change the scale on the bar graph such that it reads c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-') in the locations c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7) Any ideas? Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Change the scale on a barplot's y axis
Yay! That's perfect. Thanks, Steve! Tom 2010/2/27 S Ellison s.elli...@lgc.co.uk: Thomas, You could perhaps do a tad better by simply adding a right-hand-side axis using axis(): axis(4, at=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7), labels=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-'), las=1) That way you have both numeric and grade scales. if you want a left-hand grade scale only, first suppress the axes in the barplot using axes=FALSE, and then add the axes using axis(1) and axis(2,..) with the ... as above. Incidentally, I'm not sure I'd have converted your numbers that way, but if it's worked it's worked. Steve E Thomas Levine thomas.lev...@gmail.com 02/28/10 12:44 AM I have grades data. I read them from a csv in letter-grade format. I then converted them to levels levels(grades$grade)=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-') And then to numbers grades$gp=grades$grade levels(grades$gp)=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7) grades$gp=as.numeric(as.character(grades$gp)) And I'm plotting them in a barplot barplot(gp[order(gp)],width=n[order(gp)],ylab=Class Median Grade,xlab=Class, scaled to number of students in the class,main=Class Median Grades for Cornell University weighted by class size) I would like to change the scale on the bar graph such that it reads c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-') in the locations c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7) Any ideas? Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** This email and any attachments are confidential. Any u...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Error in tapply when reordering levels of a factor
I have this grades$grade ... [4009] A B A- A- A- B+ A A- B+ B A B B B A A- A A- A- B+ A- A A B+ [4033] A- A- A- A A- B A A A- A Levels: A A- A+ B B- B+ C C+ I want to change the order of the levels reorder(grades$grade,c('A+','A','A-','B+','B','B-','C+','C')) Error in tapply(X, x, FUN, ...) : arguments must have same length What am I doing wrong? Thanks Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] A graphic art piece I created that only statisticians would understand and the use of R in art
This isn't the typical r-help post, but I think people here will appreciate it. The current Shirt.Woot (http://shirt.woot.com) derby prompt is fake band names, so I chose the name The Probable Error of a Mean. And I made my submission with R. Here it is: http://www.thomaslevine.org/the_probable_error_of_a_mean/poster.png http://shirt.woot.com/Derby/Entry.aspx?id=33029 I'm quite surprised and disappointed by how few people understand it. It's probably not going to win, but I'll print a few fake band propaganda materials and confuse/enlighten people. This is also making me wonder what more artistic works are created using R. There is some degree of art in the creation of plots, but I'm thinking about things whose purpose is not to convey quantitative information in such a strict sense. I suspect that there's a better language/program for most non-plot curves, but are there any thoughts on this? Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to import timestamps from emails into R
One last tiny problem: How do I add months to the scale? It currently just has years http://school.thomaslevine.org/mywall.png Thanks again Tom On Sat, Jun 20, 2009 at 12:14 PM, Thomas Levine thomas.lev...@gmail.comwrote: I wasn't really thinking that far ahead; plot tries to do something, so I figured I'd try that as I had little other idea of what to do. The plot(tt) actually does what I want, though; the scales are just very messed-up. Tom On Sat, Jun 20, 2009 at 11:58 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: If that is the situation then plot(tt) in your post could not have been what you wanted in any case, e.g. plot(10:20) On Sat, Jun 20, 2009 at 11:49 AM, Thomas Levinethomas.lev...@gmail.com wrote: This produces the x-axis is the index, and the y-axis is time. It has all of the time information on the same axis, allowing me to plot cumulative occurrences by time (my original plan) if the times are sorted, which they should be. I think I'll end up using some variant of plot(tt,seq_along(tt)), putting the time axis along the bottom. Thanks Tom On Sat, Jun 20, 2009 at 11:15 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this: plot(seq_along(tt), tt) On Sat, Jun 20, 2009 at 10:55 AM, Thomas Levine thomas.lev...@gmail.com wrote: Here's what I get head(tt) [1] 2008-02-20 03:09:51 EST 2008-02-20 12:12:57 EST [3] 2008-03-05 09:11:28 EST 2008-03-05 17:59:40 EST [5] 2008-03-09 09:00:09 EDT 2008-03-29 15:57:16 EDT But I can't figure out how to plot this now. plot(tt) does not appear to be univariate. I get the same plot with plot(as.Date(tt)), which would make sense if time is used because of the range of the dates and the insignificance of the times of day. head(as.Date(tt)) [1] 2008-02-20 2008-02-20 2008-03-05 2008-03-05 2008-03-09 [6] 2008-03-29 plot(tt) and plot(as.Date(tt)) give something like year as a function of the rest of the date. Here they are Here are the addresses http://thomaslevine.org/time/tt.png http://thomaslevine.org/time/as.Date.tt.png Tom On Fri, Jun 19, 2009 at 6:21 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this: Lines - Sun, 14 Jun 2009 07:33:00 -0700 Sun, 14 Jun 2009 08:35:10 -0700 Sun, 14 Jun 2009 21:26:34 -0700 Mon, 15 Jun 2009 19:47:47 -0700 Wed, 17 Jun 2009 21:50:41 -0700 # L - readLines(myfile.txt) L - readLines(textConnection(Lines)) tt - as.POSIXct(L, format = %a, %d %b %Y %H:%M:%S) On Fri, Jun 19, 2009 at 6:06 PM, Thomas Levine thomas.lev...@gmail.com wrote: I am analysing occurrences of a phenomenon by time, and each of these timestamps taken from email headers represents one occurrence. (The last number is the time zone.) I can easily change the format. Sun, 14 Jun 2009 07:33:00 -0700 Sun, 14 Jun 2009 08:35:10 -0700 Sun, 14 Jun 2009 21:26:34 -0700 Mon, 15 Jun 2009 19:47:47 -0700 Wed, 17 Jun 2009 21:50:41 -0700 I've found documentation for a plethora of ways of importing time data, but I can't decide how to approach it. Any ideas on what may be the cleanest way? The only special concern is that I'll want to plot these data by date and time, meaning that I would rather not bin all of the occurrences from one day. The time zone isn't important as these are all local times; the time zone only changes as a function of daylight savings time, so I probably shouldn't use it at all. Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to import timestamps from emails into R
Here's what I get head(tt) [1] 2008-02-20 03:09:51 EST 2008-02-20 12:12:57 EST [3] 2008-03-05 09:11:28 EST 2008-03-05 17:59:40 EST [5] 2008-03-09 09:00:09 EDT 2008-03-29 15:57:16 EDT But I can't figure out how to plot this now. plot(tt) does not appear to be univariate. I get the same plot with plot(as.Date(tt)), which would make sense if time is used because of the range of the dates and the insignificance of the times of day. head(as.Date(tt)) [1] 2008-02-20 2008-02-20 2008-03-05 2008-03-05 2008-03-09 [6] 2008-03-29 plot(tt) and plot(as.Date(tt)) give something like year as a function of the rest of the date. Here they are [image: tt.png] [image: as.Date.tt.png] Here are the addresses http://thomaslevine.org/time/tt.png http://thomaslevine.org/time/as.Date.tt.png Tom On Fri, Jun 19, 2009 at 6:21 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this: Lines - Sun, 14 Jun 2009 07:33:00 -0700 Sun, 14 Jun 2009 08:35:10 -0700 Sun, 14 Jun 2009 21:26:34 -0700 Mon, 15 Jun 2009 19:47:47 -0700 Wed, 17 Jun 2009 21:50:41 -0700 # L - readLines(myfile.txt) L - readLines(textConnection(Lines)) tt - as.POSIXct(L, format = %a, %d %b %Y %H:%M:%S) On Fri, Jun 19, 2009 at 6:06 PM, Thomas Levinethomas.lev...@gmail.com wrote: I am analysing occurrences of a phenomenon by time, and each of these timestamps taken from email headers represents one occurrence. (The last number is the time zone.) I can easily change the format. Sun, 14 Jun 2009 07:33:00 -0700 Sun, 14 Jun 2009 08:35:10 -0700 Sun, 14 Jun 2009 21:26:34 -0700 Mon, 15 Jun 2009 19:47:47 -0700 Wed, 17 Jun 2009 21:50:41 -0700 I've found documentation for a plethora of ways of importing time data, but I can't decide how to approach it. Any ideas on what may be the cleanest way? The only special concern is that I'll want to plot these data by date and time, meaning that I would rather not bin all of the occurrences from one day. The time zone isn't important as these are all local times; the time zone only changes as a function of daylight savings time, so I probably shouldn't use it at all. Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to import timestamps from emails into R
This produces the x-axis is the index, and the y-axis is time. It has all of the time information on the same axis, allowing me to plot cumulative occurrences by time (my original plan) if the times are sorted, which they should be. I think I'll end up using some variant of plot(tt,seq_along(tt)), putting the time axis along the bottom. Thanks Tom On Sat, Jun 20, 2009 at 11:15 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this: plot(seq_along(tt), tt) On Sat, Jun 20, 2009 at 10:55 AM, Thomas Levinethomas.lev...@gmail.com wrote: Here's what I get head(tt) [1] 2008-02-20 03:09:51 EST 2008-02-20 12:12:57 EST [3] 2008-03-05 09:11:28 EST 2008-03-05 17:59:40 EST [5] 2008-03-09 09:00:09 EDT 2008-03-29 15:57:16 EDT But I can't figure out how to plot this now. plot(tt) does not appear to be univariate. I get the same plot with plot(as.Date(tt)), which would make sense if time is used because of the range of the dates and the insignificance of the times of day. head(as.Date(tt)) [1] 2008-02-20 2008-02-20 2008-03-05 2008-03-05 2008-03-09 [6] 2008-03-29 plot(tt) and plot(as.Date(tt)) give something like year as a function of the rest of the date. Here they are Here are the addresses http://thomaslevine.org/time/tt.png http://thomaslevine.org/time/as.Date.tt.png Tom On Fri, Jun 19, 2009 at 6:21 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this: Lines - Sun, 14 Jun 2009 07:33:00 -0700 Sun, 14 Jun 2009 08:35:10 -0700 Sun, 14 Jun 2009 21:26:34 -0700 Mon, 15 Jun 2009 19:47:47 -0700 Wed, 17 Jun 2009 21:50:41 -0700 # L - readLines(myfile.txt) L - readLines(textConnection(Lines)) tt - as.POSIXct(L, format = %a, %d %b %Y %H:%M:%S) On Fri, Jun 19, 2009 at 6:06 PM, Thomas Levinethomas.lev...@gmail.com wrote: I am analysing occurrences of a phenomenon by time, and each of these timestamps taken from email headers represents one occurrence. (The last number is the time zone.) I can easily change the format. Sun, 14 Jun 2009 07:33:00 -0700 Sun, 14 Jun 2009 08:35:10 -0700 Sun, 14 Jun 2009 21:26:34 -0700 Mon, 15 Jun 2009 19:47:47 -0700 Wed, 17 Jun 2009 21:50:41 -0700 I've found documentation for a plethora of ways of importing time data, but I can't decide how to approach it. Any ideas on what may be the cleanest way? The only special concern is that I'll want to plot these data by date and time, meaning that I would rather not bin all of the occurrences from one day. The time zone isn't important as these are all local times; the time zone only changes as a function of daylight savings time, so I probably shouldn't use it at all. Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to import timestamps from emails into R
I am analysing occurrences of a phenomenon by time, and each of these timestamps taken from email headers represents one occurrence. (The last number is the time zone.) I can easily change the format. Sun, 14 Jun 2009 07:33:00 -0700 Sun, 14 Jun 2009 08:35:10 -0700 Sun, 14 Jun 2009 21:26:34 -0700 Mon, 15 Jun 2009 19:47:47 -0700 Wed, 17 Jun 2009 21:50:41 -0700 I've found documentation for a plethora of ways of importing time data, but I can't decide how to approach it. Any ideas on what may be the cleanest way? The only special concern is that I'll want to plot these data by date and time, meaning that I would rather not bin all of the occurrences from one day. The time zone isn't important as these are all local times; the time zone only changes as a function of daylight savings time, so I probably shouldn't use it at all. Tom [[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] Labeling barplot bars by multiple factors
Both of those worked, but hierobarp looked a bit easier, so I used that. The one annoying thing is that it sorts alphabetically. Tom On Thu, May 28, 2009 at 6:46 AM, Jim Lemon j...@bitwrit.com.au wrote: Thomas Levine wrote: I want to plot quantitative data as a function of three two-level factors. How do I group the bars on a barplot by level through labeling and spacing? Here http://www.thomaslevine.org/sample_multiple-factor_barplot.png's what I'm thinking of. Also, I'm pretty sure that I want a barplot, but there may be something better. Hi Tom, You may find that the hierobarp function in the plotrix package will do what you want. Jim [[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] Labeling barplot bars by multiple factors
Ah, that makes sense. But now another two issues have arisen. Firstly, the error bars look like confidence intervals, and I'm pretty sure that they are but does some document verify this? I suppose I could check the code too. Secondly, I just read about how dynamite plots should be avoided. It's quite easy to turn the dynamite plots into dot plots with Inkscape, but is there an equivalent function that generates _hierarchical_ dot plots? Tom On Thu, May 28, 2009 at 12:32 PM, William Dunlap wdun...@tibco.com wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas Levine Sent: Thursday, May 28, 2009 5:04 AM To: Jim Lemon Cc: r-help@r-project.org Subject: Re: [R] Labeling barplot bars by multiple factors Both of those worked, but hierobarp looked a bit easier, so I used that. The one annoying thing is that it sorts alphabetically. Tom The sorts of functions almost always order things by the order of the levels of your factors. The default ordering is alphabetical (or increasing numeric, if your factor was made from numerical data). To change the order remake the factor and supply the levels argument. E.g., to reverse the order use rev: data$someFactor - factor(data$someFactor, levels=rev(levels(data$someFactor))) Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com On Thu, May 28, 2009 at 6:46 AM, Jim Lemon j...@bitwrit.com.au wrote: Thomas Levine wrote: I want to plot quantitative data as a function of three two-level factors. How do I group the bars on a barplot by level through labeling and spacing? Here http://www.thomaslevine.org/sample_multiple-factor_barplot.png's what I'm thinking of. Also, I'm pretty sure that I want a barplot, but there may be something better. Hi Tom, You may find that the hierobarp function in the plotrix package will do what you want. Jim [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Labeling barplot bars by multiple factors
I want to plot quantitative data as a function of three two-level factors. How do I group the bars on a barplot by level through labeling and spacing? Here http://www.thomaslevine.org/sample_multiple-factor_barplot.png's what I'm thinking of. Also, I'm pretty sure that I want a barplot, but there may be something better. Tom [[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] Error in FUN with tapply and by
A subset of my raw data looks like this: -- Grip Technique Baseline.integrated Task Stroke..direction.Engag Disen PenDG PenUG PenDS PenUS Duration - Tripod,Barrel,Integrated,7,S70,230,510,270,510,781,1011,1011 Tripod,Barrel,Integrated,7,S71,na,na,na,na,na,na,na Round,NonPrefHand,Baseline,0,S00,na,na,110,250,380,520,520 Round,NonPrefHand,Baseline,0,S01,na,na,220,360,460,620,620 -- I computed some values (times) from the raw data --- t_p1=PenDG t_c1=PenUG-PenDG t_p2=PenDS-PenUG t_c2=PenUS-PenDS --- And I put those times in a data frame called times. For each of these times, I want to subtract the average for Baseline trials from the average for Integrated trials within the Grip and Technique factors. Call these differences the true cost of mode selection. truecost - function(time){as.numeric(tapply(time,Baseline.integrated,mean,na.rm=T)[2]-tapply(time,Baseline.integrated,mean,na.rm=T)[1])} To help explain what the truecost function does: tapply(t_p1,Baseline.integrated,mean,na.rm=T) Baseline Integrated 212.8000 252.8402 truecost(t_p1) [1] 40.04021 Then I try to create a table of average truecost as a function of levels of a factor. I think this is the same error with tapply and by. tapply(t_p1,list(Grip,Technique),truecost,na.rm=T) Error in FUN(X[[1L]], ...) : unused argument(s) (na.rm = TRUE) by(times,list(Grip,Technique),truecost,na.rm=T) Error in FUN(data[x, , drop = FALSE], ...) : unused argument(s) (na.rm = TRUE) Any ideas? Thomas Levine! [[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] Error in FUN with tapply and by
str(time) function (x, ...) str(t_p1) num [1:576] 190 180 190 200 210 200 220 190 230 230 ... str(Baseline.integrated) Factor w/ 2 levels Baseline,Integrated: 1 1 1 1 1 1 1 1 1 1 ... str(Technique) Factor w/ 2 levels Barrel,NonPrefHand: 1 1 1 1 1 1 1 1 1 1 ... str(Grip) Factor w/ 2 levels Round,Tripod: 1 1 1 1 1 1 1 1 1 1 ... On Fri, May 22, 2009 at 2:46 PM, jim holtman jholt...@gmail.com wrote: You need to supply str for the original arguments; the error message had a different set of parameters. On Fri, May 22, 2009 at 2:36 PM, Thomas Levine thomas.lev...@gmail.comwrote: That produces the following error tapply(t_p1,list(Grip,Technique),truecost) Error in tapply(time, Baseline.integrated, mean, na.rm = T) : arguments must have same length On Fri, May 22, 2009 at 1:06 PM, jim holtman jholt...@gmail.com wrote: Error message is self-explanatory: there is an unused parameter 'na.rm=TRUE'. You are calling your function 'truecost' which only has a single parameter 'time' and you are attempting to pass in 'na.rm=TRUE' which it will not accept. You don't need it. On Fri, May 22, 2009 at 12:36 PM, Thomas Levine thomas.lev...@gmail.com wrote: A subset of my raw data looks like this: -- Grip Technique Baseline.integrated Task Stroke..direction.Engag Disen PenDG PenUG PenDS PenUS Duration - Tripod,Barrel,Integrated,7,S70,230,510,270,510,781,1011,1011 Tripod,Barrel,Integrated,7,S71,na,na,na,na,na,na,na Round,NonPrefHand,Baseline,0,S00,na,na,110,250,380,520,520 Round,NonPrefHand,Baseline,0,S01,na,na,220,360,460,620,620 -- I computed some values (times) from the raw data --- t_p1=PenDG t_c1=PenUG-PenDG t_p2=PenDS-PenUG t_c2=PenUS-PenDS --- And I put those times in a data frame called times. For each of these times, I want to subtract the average for Baseline trials from the average for Integrated trials within the Grip and Technique factors. Call these differences the true cost of mode selection. truecost - function(time){as.numeric(tapply(time,Baseline.integrated,mean,na.rm=T)[2]-tapply(time,Baseline.integrated,mean,na.rm=T)[1])} To help explain what the truecost function does: tapply(t_p1,Baseline.integrated,mean,na.rm=T) Baseline Integrated 212.8000 252.8402 truecost(t_p1) [1] 40.04021 Then I try to create a table of average truecost as a function of levels of a factor. I think this is the same error with tapply and by. tapply(t_p1,list(Grip,Technique),truecost,na.rm=T) Error in FUN(X[[1L]], ...) : unused argument(s) (na.rm = TRUE) by(times,list(Grip,Technique),truecost,na.rm=T) Error in FUN(data[x, , drop = FALSE], ...) : unused argument(s) (na.rm = TRUE) Any ideas? Thomas Levine! [[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? -- 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] Plotting multiple ablines
I've really been on a roll this week; the formula for the lines that I presented was completely wrong. But I'm glad I learned about mapply. I used this: mapply(abline, (converge$kY + tan((90-converge$kT) * pi / 180)*(-converge$kX)), tan((90-converge$kT) * pi / 180)) Tom! On Thu, Apr 2, 2009 at 8:29 AM, r...@quantide.com r...@quantide.com wrote: May be: plot(c(-1, 1) , c(-1, 1), type = n) n = 4 a = rep(0, n) b = 1:n/n fun = function(i, a, b, col = 1 , ...) { abline(a[i], b[i], col = col[i], ...) } lapply(1:n, fun, a=a, b=b, col = 1:n) Andrea Thomas Levine wrote: I really want to do this: abline( a=tan(-kT*pi/180), b=kY-tan(-kT*pi/180)*kX ) where kX,kY and kT are vectors of equal length. But I can't do that with abline unless I use a loop, and I haven't figured out the least unelegant way of writing the loop yet. So is there a way to do this without a loop? Or if I am to resort to the loop, what's the best way of doing it considering that I have some missing data? Here's the mess that I wrote. converge - na.omit(data.frame(kX,kY,kT)) for (z in (length(converge$kT))) {abline( a=tan(converge$kT[z]*pi/180), b=converge$kY[z]-tan(-converge$kT[z]*converge$kX[z]*pi/180) )} I think the missing data are causing the problem; this happens when I run: Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : 'a' and 'b' must be finite __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plotting multiple ablines
I really want to do this: abline( a=tan(-kT*pi/180), b=kY-tan(-kT*pi/180)*kX ) where kX,kY and kT are vectors of equal length. But I can't do that with abline unless I use a loop, and I haven't figured out the least unelegant way of writing the loop yet. So is there a way to do this without a loop? Or if I am to resort to the loop, what's the best way of doing it considering that I have some missing data? Here's the mess that I wrote. converge - na.omit(data.frame(kX,kY,kT)) for (z in (length(converge$kT))) {abline( a=tan(converge$kT[z]*pi/180), b=converge$kY[z]-tan(-converge$kT[z]*converge$kX[z]*pi/180) )} I think the missing data are causing the problem; this happens when I run: Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : 'a' and 'b' must be finite __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Plot the highest point in a contour plot
I'm plotting contour plots with contourplot. which.max gives me the index of the highest point of a matrix. I can find the point in the matrix from here, convert it to a point on a graph and add it with points, but you'd think someone's already written this. How do I plot the highest point in a contourplot automatically? Tom [[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] Contour plots of four two-dimensional matrices
I have four large two-dimensional matrices of which I want to create contour plots. Something like filled.contour(matrix) contourplot(matrix) works but only gives me one plot at a time. If I combine the four matrices into one three-dimensional matrix, which I'll name seven, there should be a way of doing something like this contourplot(seven[,,k] for k in 1 to 4) such that they come out as one plot rather than four. I couldn't figure out how to do this, so I tried a disgusting alternative that involved generating x,y and k vectors, but I'd rather do it properly. Tom [[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] Contour plots of four two-dimensional matrices
I want to plot them side by side. On Sun, Mar 15, 2009 at 12:41 PM, David Winsemius dwinsem...@comcast.netwrote: What is it that you want to do with these 4 plots? Overlay them with different color contours or plot them side-by-side on the same page? ?par # for filled.contour but the implementation will be different for those two options. contourplot is is a lattice plotting function. See Figure 6.10 on Sarkar's Lattice book pages. levelplot is the closest analog to filled contour in lattice. -- David Winsemius On Mar 15, 2009, at 12:22 PM, Thomas Levine wrote: I have four large two-dimensional matrices of which I want to create contour plots. Something like filled.contour(matrix) contourplot(matrix) works but only gives me one plot at a time. If I combine the four matrices into one three-dimensional matrix, which I'll name seven, there should be a way of doing something like this contourplot(seven[,,k] for k in 1 to 4) such that they come out as one plot rather than four. I couldn't figure out how to do this, so I tried a disgusting alternative that involved generating x,y and k vectors, but I'd rather do it properly. Tom [[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. David Winsemius, MD Heritage Laboratories West Hartford, CT [[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] Inefficiency of SAS Programming
R depends on all of those things to run, but you only have to use those programs through R. The software depends on these other tools, but the human doesn't have to switch interfaces. Tom! On Fri, Feb 27, 2009 at 9:22 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Fri, Feb 27, 2009 at 8:53 AM, Frank E Harrell Jr f.harr...@vanderbilt.edu wrote: Ajay ohri wrote: Sometimes for the sake of simplicity, SAS coding is created like that. One can use the concatenate function and drag and drop in an simple excel sheet for creating elaborate SAS code like the one mentioned and without any time at all. A system that requires Excel for its success is not a complete system. To be fair R depends on perl (although this dependence seems to be decreasing lately and possibly will be eliminated), latex and a bunch of unix tools. Developing GUIs depends on tcl/tk or other external system and developing fast code can require that some of it be written in C. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Download daily weather data
Geonames unfortunately doesn't have weather forecasts. This is a problem. GRIB looks better. There is an interface between GRIB and R. On Fri, Feb 27, 2009 at 4:14 AM, Pfaff, Bernhard Dr. bernhard_pf...@fra.invesco.com wrote: Dear Thomas, more for the sake of completeness and as an alternative to R. There are GRIB data [1] sets available (some for free) and there is the GPL software Grads [2]. Because the Grib-Format is well documented it should be possible to get it into R easily and make up your own plots/weather analyis. I do not know and have not checked if somebody has already done so. I use this information/tools aside of others during longer-dated off-shore sailing. Best, Bernhard [1] http://www.grib.us/ [2] http://www.iges.org/grads/ -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Scillieri, John Gesendet: Donnerstag, 26. Februar 2009 22:58 An: 'James Muller'; 'r-help@r-project.org' Betreff: Re: [R] Download daily weather data Looks like you can sign up to get XML feed data from Weather.com http://www.weather.com/services/xmloap.html Hope it works out! -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of James Muller Sent: Thursday, February 26, 2009 3:57 PM To: r-help@r-project.org Subject: Re: [R] Download daily weather data Thomas, Have a look at the source code for the webpage (ctrl-u in firefox, don't know in internet explorer, etc.). That is what you'd have to parse in order to get the forecast from this page. Typically when I parse webpages such as this I use regular expressions to do so (and I would never downplay the usefulness of regular expressions, but they take a little getting used to). There are two parts to the task: find patterns that allow you to pull out the datum/data you're after; and then write a program to pull it/them out. Also, of course, download the webpage (but that's no issue). I bet you'd be able to find a comma separated value (CSV) file containing the weather report somewhere, which would probably involve a little less labor in order to produce your automatic wardrobe advice. James On Thu, Feb 26, 2009 at 3:47 PM, Thomas Levine thomas.lev...@gmail.com wrote: I'm writing a program that will tell me whether I should wear a coat, so I'd like to be able to download daily weather forecasts and daily reports of recent past weather conditions. The NOAA has very promising tabular forecasts (http://forecast.weather.gov/MapClick.php?CityName=Ithacastate =NYsite=BGMtextField1=42.4422textField2=-76.5002e=0FcstType=digital), but I can't figure out how to import them. Someone must have needed to do this before. Suggestions? Thomas Levine! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. This e-mail and any attachments are confidential, may contain legal, professional or other privileged information, and are intended solely for the addressee. If you are not the intended recipient, do not use the information in this e-mail in any way, delete this e-mail and notify the sender. CEG-IP1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. * Confidentiality Note: The information contained in this ...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Inefficiency of SAS Programming
I had enrolled in a statistics course this semester, but after the first class, I dropped it because it uses SAS. This thread makes me quite glad. Tom! On Fri, Feb 27, 2009 at 8:48 AM, Frank E Harrell Jr f.harr...@vanderbilt.edu wrote: Wensui Liu wrote: Thanks for pointing me to the SAS code, Dr Harrell After reading codes, I have to say that the inefficiency is not related to SAS language itself but the SAS programmer. An experienced SAS programmer won't use much of hard-coding, very adhoc and difficult to maintain. I agree with you that in the SAS code, it is a little too much to evaluate predictions. such complex data step actually can be replaced by simpler iml code. Agreed that the SAS code could have been much better. I programmed in SAS for 23 years and would have done it much differently. But you will find that the most elegant SAS program re-write will still be a far cry from the elegance of R. Frank On Thu, Feb 26, 2009 at 5:57 PM, Frank E Harrell Jr f.harr...@vanderbilt.edu wrote: If anyone wants to see a prime example of how inefficient it is to program in SAS, take a look at the SAS programs provided by the US Agency for Healthcare Research and Quality for risk adjusting and reporting for hospital outcomes at http://www.qualityindicators.ahrq.gov/software.htm . The PSSASP3.SAS program is a prime example. Look at how you do a vector product in the SAS macro language to evaluate predictions from a logistic regression model. I estimate that using R would easily cut the programming time of this set of programs by a factor of 4. Frank -- 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. -- 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Download daily weather data
I'm writing a program that will tell me whether I should wear a coat, so I'd like to be able to download daily weather forecasts and daily reports of recent past weather conditions. The NOAA has very promising tabular forecasts (http://forecast.weather.gov/MapClick.php?CityName=Ithacastate=NYsite=BGMtextField1=42.4422textField2=-76.5002e=0FcstType=digital), but I can't figure out how to import them. Someone must have needed to do this before. Suggestions? Thomas Levine! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Download daily weather data
Perhaps coat and jacket are more ambiguous in the United States than the United Kingdom. If it's cold enough to warrant it, I wear a jacket in the morning. If it isn't, I don't want to have to carry it around all day. Checking the daily weather forecast is too much work, so I just go by the current temperature in the morning, which leads to many false positives. Thomas Levine! On Thu, 2009-02-26 at 22:51 +, Barry Rowlingson wrote: 2009/2/26 Thomas Levine thomas.lev...@gmail.com: I'm writing a program that will tell me whether I should wear a coat, so I'd like to be able to download daily weather forecasts and daily reports of recent past weather conditions. The NOAA has very promising tabular forecasts (http://forecast.weather.gov/MapClick.php?CityName=Ithacastate=NYsite=BGMtextField1=42.4422textField2=-76.5002e=0FcstType=digital), but I can't figure out how to import them. Someone must have needed to do this before. Suggestions? You could use my geonames package that uses the GeoNames query service. There's a sample queries here: http://geonames.r-forge.r-project.org/ Easiest is probably to use GNfindNearByWeather: as.data.frame(GNfindNearByWeather(57,-2)) clouds weatherCondition 1 broken clouds n/a observation windDirection ICAO 1 EGPD 262120Z 25003KT 9000 -RA BKN018 06/05 Q1012 NOSIG 250 EGPD elevation countryCode lng temperature dewPoint windSpeed humidity 165 GB -2.216667 6503 93 stationNamedatetime lat hectoPascAltimeter 1 Aberdeen / Dyce 2009-02-26 21:20:00 57.2 1012 The package is on CRAN. There is of course an easier way to decide if you need to wear a coat, and that is to look out the window :) Barry signature.asc Description: This is a digitally signed message part __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Putting all independent variables in one variable so performing many similar tests is more convenient
I want to do something like this. avo(q~a+b+c+d+e+f+g+h+i+j+k+l) avo(r~a+b+c+d+e+f+g+h+i+j+k+l) avo(s~a+b+c+d+e+f+g+h+i+j+k+l) (There's likely a better way to do this actually, but I think this'll work.) How do I define e=a+b+c+d+e+f+g+h+i+j+k+l such that the following works? avo(q~e) avo(r~e) avo(s~e) Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Putting all independent variables in one variable so performing many similar tests is more convenient
oops, I mean aov On Sun, Feb 1, 2009 at 9:27 AM, Thomas Levine thomas.lev...@gmail.com wrote: I want to do something like this. avo(q~a+b+c+d+e+f+g+h+i+j+k+l) avo(r~a+b+c+d+e+f+g+h+i+j+k+l) avo(s~a+b+c+d+e+f+g+h+i+j+k+l) (There's likely a better way to do this actually, but I think this'll work.) How do I define e=a+b+c+d+e+f+g+h+i+j+k+l such that the following works? avo(q~e) avo(r~e) avo(s~e) Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 should I organize data to compare differences in matchedpairs?
I have everything in the data frame now. The calculations I need to preform for each round are slightly different. How do I specify to make one calculation for one round and one for the other? (One round is called C, and the other is F) Thomas Levine On Thu, 2008-01-24 at 18:23 -0500, Thomas Levine wrote: By accident, I didn't send this to the list. On Thu, 2008-01-24 at 17:54 -0500, Thomas Levine wrote: Oh, right, I don't need the differences. I only needed to get the differences before because I was doing them sloppily in a spreadsheet and needed to do a t-test manually because the program didn't have a function for one type of t-test. I shall do it this way then. On Thu, 2008-01-24 at 12:05 -0700, Greg Snow wrote: Here is how I would do it (there are multiple ways you could do it, so there is not single Right answer): Assign each person a unique identifier. Put all the information from the questionaire along with the idenifier and anything else that does not change between rounds (age, sex, height, ...) into one data frame. This df will have as many rows as you have subjects. The round information then goes into a second data frame with each round being a row (each subject has multiple rows) and include the unique identifier on each row for that person. If you need information combined from both data frames, then use the merge function to merge the 2 data frames (or subsets of them) together. Advantages of this method include: Uses data frames which most of the analysis functions expect. Each piece of data is only entered once (other than the id) Disadvantage: Data is split between 2 objects. Hope this helps, signature.asc Description: This is a digitally signed message part __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 should I organize data to compare differences in matched pairs?
I'm just learning how to use R right now, so I'm not sure what the most efficient way to organize these data is. I had subjects perform the same task twice with slight changes between the rounds. I want to analyze differences between the rounds. All of the subjects also answered a questionnaire. Putting all of one subject's information on one row seems sloppy. I was thinking about making a three-dimensional array with subject number, round and measurement as axes, but then the differences would have to be the third column in the round axis, which also seemed messy. Also, I would have duplicates of all of the information from the questionnaire, which seems inefficient. Or maybe I could just use a matrix where round is just another column among all of the measurements. This is similar to the previous arrangement, but I don't know which is better. It still has all of the duplicated information that the previous method has. Anyway, I'm sure someone's done this before, so I'd like to see what other people have done for data like these. Thomas Levine [[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 should I organize data to compare differences in matchedpairs?
By accident, I didn't send this to the list. On Thu, 2008-01-24 at 17:54 -0500, Thomas Levine wrote: Oh, right, I don't need the differences. I only needed to get the differences before because I was doing them sloppily in a spreadsheet and needed to do a t-test manually because the program didn't have a function for one type of t-test. I shall do it this way then. On Thu, 2008-01-24 at 12:05 -0700, Greg Snow wrote: Here is how I would do it (there are multiple ways you could do it, so there is not single Right answer): Assign each person a unique identifier. Put all the information from the questionaire along with the idenifier and anything else that does not change between rounds (age, sex, height, ...) into one data frame. This df will have as many rows as you have subjects. The round information then goes into a second data frame with each round being a row (each subject has multiple rows) and include the unique identifier on each row for that person. If you need information combined from both data frames, then use the merge function to merge the 2 data frames (or subsets of them) together. Advantages of this method include: Uses data frames which most of the analysis functions expect. Each piece of data is only entered once (other than the id) Disadvantage: Data is split between 2 objects. Hope this helps, signature.asc Description: This is a digitally signed message part __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.