[R] Create a time-series from cross-sectional data that has each year as a separate column
Hi, I have a dataset from ILO, originally in csv-format, that I have read into R. It is cross-sectional time-series data, so I have a bunch of variables and dummy variables that I need to extract data from for the entire time period. However, the years are separated by columns instead of rows, as is usually the case in R. This is what it looks like: str(laborstafinMFBA) 'data.frame': 152 obs. of 39 variables: $ COUNTRY: Factor w/ 164 levels Albania,Algeria,..: 2 4 7 8 9 10 11 11 12 13 ... $ CODE.COUNTRY : Factor w/ 163 levels AE,AG,AI,..: 44 7 8 5 12 11 10 10 13 23 ... $ SOURCE : Factor w/ 7 levels Administrative reports,..: 3 3 3 3 3 3 3 3 3 3 ... $ CODE.SOURCE: Factor w/ 7 levels A,B,BA,CA,..: 3 3 3 3 3 3 3 3 3 3 ... etc.. $ D1990 : num NA NA NA NA NA ... $ D1991 : num NA NA 101 NA NA ... $ D1992 : num NA 38.4 111.2 NA NA ... $ D1993 : num NA NA 94.4 NA NA ... $ D1994 : num NA NA 133.69 NA 1.42 ... $ D1995 : num NA NA 121 NA NA ... $ D1996 : num NA NA 176 NA NA ... $ D1997 : num NA NA 195.31 NA 1.51 ... $ D1998 : num NA NA 202 NA NA ... $ D1999 : num NA NA 201 NA NA ... $ D2000 : num NA NA 207 NA NA ... $ D2001 : num 68.1 NA 198.3 NA NA ... $ D2002 : num NA NA 186 NA NA ... $ D2003 : num 67.6 NA 148.8 NA NA ... $ D2004 : num 68.8 NA 143.7 NA NA ... $ D2005 : num NA NA 163 NA NA ... $ D2006 : num NA NA 189 NA NA ... $ D2007 : num NA NA NA 14 1.91 ... How do I transform this into something that I can make a time-series of? Sincerely, Gabriel Bergin gabr...@bergin.se [[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] ggplot bar geom: control the filling in the colour legend
Hi all, I'm still seeking for tweaking the appearance of the color legend in a bar goemetry with ggplot2. I can't seem to control the filling of the colour legend squares take this, ggplot(diamonds, aes(clarity, fill=color,colour = cut)) + geom_bar(position = dodge) and I'd need a white filling in the colour legend, instead of the black one. Does anyone know how to rule that? All the best Le 11/09/2010 10:27, Benoit Boulinguiez a écrit : Sorry my bad, example too simple try that one out. ggplot(diamonds, aes(clarity, fill=color,colour = cut)) + geom_bar(position = dodge) I want change the filling in the colour legend, not the filling of the bars. Regards Le 10/09/2010 20:41, Ista Zahn a écrit : ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar(fill=white) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] create a '3D line plot'
On 09/13/2010 06:17 AM, Karl Brand wrote: Cheers! All excellent, runable examples helping me progress quickly. Being more a qualitative plot, the y-axis is less important. But it did get me thinking- Coloring each of the plotted lines, say 'altitude colors' like the classic volcano example to reflect the (scaled) values the lines represent might be effective at representing individual y-axis magnitude for each line. Perhaps gray background at least. Maybe if there were examples of the lines() func. using colors dependent on the y-value? Or some one already made a function for achieving this? (Google didnt return anything obvious for me...yet). Hi Karl, Have a look at the clplot and color.scale.lines functions in the plotrix package. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SOLVED boxplot knowing Q1, Q3, median, upper and lower whisker value
Thank you all for your comments. The bxp() function does the trick well! Subject: RE: [R] boxplot knowing Q1, Q3, median,upper and lower whisker value Date: Fri, 10 Sep 2010 11:00:06 -0700 From: wdun...@tibco.com To: dig...@ohsu.edu; dasol...@hotmail.com CC: r-help@r-project.org is.nan(bd.coerce(as.bdVector(c(1.0, N -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Brian Diggs Sent: Thursday, September 09, 2010 12:41 PM To: David A. Cc: R-help Subject: Re: [R] boxplot knowing Q1, Q3, median,upper and lower whisker value On 9/6/2010 8:46 AM, David A. wrote: Dear list, I am using a external program that outputs Q1, Q3, median, upper and lower whisker values for various datasets simultaneously in a tab delimited format. After importing this text file into R, I would like to plot a boxplot using these given values and not the original series of data points, i.e. not using something like boxplot(mydata). Is there an easy way for doing this? If I am not wrong, boxplot() does not accept these values as parameters. I believe boxplot(x,y,z) computes the required statistics and passes them to the bxp() function for plotting. If you have the statistics you can pass them to bxp() yourself. You might call trace(bxp) followed by a call to boxplot() to see how boxplot uses bxp. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com Cheers, Dave [[alternative HTML version deleted]] If you use ggplot2, you can specify the aesthetics lower, upper, middle, ymin, and ymax directly to variables in geom_boxplot. Just be sure to set stat=identity so that it does not try to summarize your data again. -- Brian Diggs Senior Research Associate, Department of Surgery Oregon Health Science 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. [[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 generate a particular sequence ?
Dear R, I have a vector, say a = c(1,2,4,5,6,8). Can I generate a vector or array (2-by-3-by-3) of this form c(1,2,1,2,1,2,4,5,4,5,4,5,6,8,6,8,6,8), in which every two elements in a have been repeated twice? I am to stupid today and could not figure this simple question out... Many many thanks! Feng -- Feng Li Department of Statistics Stockholm University 106 91 Stockholm, Sweden http://feng.li/ [[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 generate a particular sequence ?
On 09/13/2010 07:19 PM, Feng Li wrote: Dear R, I have a vector, say a = c(1,2,4,5,6,8). Can I generate a vector or array (2-by-3-by-3) of this form c(1,2,1,2,1,2,4,5,4,5,4,5,6,8,6,8,6,8), in which every two elements in a have been repeated twice? I am to stupid today and could not figure this simple question out... Many many thanks! Hi Feng, I would take a quick look at the help for rep and c, but I would first suggest that you count the number of times that the elements are to be repeated. While you have made the definition of the problem reasonably clear with your example, there are an awful lot of combinations of every two elements of a, whether you want to repeat them two or three times. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Saveing plot to multiple locations
Hi Im trying to save a plot both to a pdf and as just a picture but without success so if someone can help me I would be happy :) my code: require(party) irisct - ctree(Species ~ .,data = iris) data(iris) attach(iris) pdf('/home/joel/Skrivbord/mammamu.pdf') try(png('/home/joel/Skrivbord/mammamu1.png')) plot(Sepal.Length, Petal.Length, col=unclass(Species)) legend(4.5, 7, levels(Species), col=plot_colors, cex=0.8, fill=1:3) try(png('/home/joel/Skrivbord/mammamu2.png')) plot(irisct) dev.off() readBin(pic,'raw',1024*1024) readBin('/home/joel/Skrivbord/mammamu2.png','raw',1024*1024) Ive tryed to move around the png and pdf part to see if it worked better if they where in an other order but as I said without success. //Joel -- View this message in context: http://r.789695.n4.nabble.com/Saveing-plot-to-multiple-locations-tp2537133p2537133.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to generate a particular sequence ?
On 13-Sep-10 09:19:21, Feng Li wrote: Dear R, I have a vector, say a = c(1,2,4,5,6,8). Can I generate a vector or array (2-by-3-by-3) of this form c(1,2,1,2,1,2,4,5,4,5,4,5,6,8,6,8,6,8) in which every two elements in a have been repeated twice? I am to stupid today and could not figure this simple question out... Many many thanks! Feng A possible solution (somewhat generalisable): a - c(1,2,4,5,6,8) Reps - 3 pairs - matrix(a,nrow=2) as.vector(pairs[,rep(c(1,2,3),each=Reps)]) # [1] 1 2 1 2 1 2 4 5 4 5 4 5 6 8 6 8 6 8 (By the way, you have 3 repetitions but wrote twice -- I assume you meant thrice but the above generalises to 2 repetitions ... :) Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 13-Sep-10 Time: 10:42:46 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 generate a particular sequence ?
Ted Harding ted.hard...@manchester.ac.uk wrote in message news:xfmail.100913104250.ted.hard...@manchester.ac.uk... On 13-Sep-10 09:19:21, Feng Li wrote: Dear R, I have a vector, say a = c(1,2,4,5,6,8). Can I generate a vector or array (2-by-3-by-3) of this form c(1,2,1,2,1,2,4,5,4,5,4,5,6,8,6,8,6,8) in which every two elements in a have been repeated twice? I am to stupid today and could not figure this simple question out... Many many thanks! Feng A possible solution (somewhat generalisable): a - c(1,2,4,5,6,8) Reps - 3 pairs - matrix(a,nrow=2) as.vector(pairs[,rep(c(1,2,3),each=Reps)]) # [1] 1 2 1 2 1 2 4 5 4 5 4 5 6 8 6 8 6 8 (By the way, you have 3 repetitions but wrote twice -- I assume you meant thrice but the above generalises to 2 repetitions ... :) Ted. The pedant in me couldn't resist asking: If he'd said repeated once would you expect only one occurence of each pair? Sorry. I'll get my coat Keith J __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] update and rebuild all?
update.packages(checkBuilt=TRUE) Uwe Ligges On 24.08.2010 11:08, Giovanni Azua wrote: Hello, I upgraded my Mac R version to the newest 2.11.1, then I ran the option to update all packages but there was an error related to fetching one of those and the process stopped. I retried updating all packages but nothing happens. Although all my course project scripts work perfectly is there a way e.g. a command to manually fetch (most up to date version) and locally build all installed packages? to make sure it is all ok? I recall there was something like that but don't remember what command it was. Thanks in advance, Best regards, Giovanni __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 cannot be started
On 07.09.2010 18:53, Tao wrote: I used Rtools for installing a package under Windows XP. I used commands like R CMD INSTALL (build, check) in the CMD window. It worked well until I found that my revised package can be updated with R CMD INSTALL. After I restarted my computer, R cannot be started any more. I double click the R icon, it gives me no response. I tried to start R in the CMD window, it gives me an error message like R for Windows front-end has encountered a problem and needs to close. We are sorry for the inconvenience. The error signature is like AppName: r.exe AppVer: 2.100.50208.0 ModName: msvcrt.dll ModVer: 7.0.2600.2180Offset: 000360cb Sounds like your OS or R is broken now. Perhaps an upate of your OS or a corrupted file / filesystem on your hard disc? This is probably not an R problem. Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SF-36 questionnaire scoring for R?
Dear useRs from the physiology department, Does someone know of an implementation of the SF-36 questionnaire scoring in R? I only found SAS and STATA versions, e.g http://gim.med.ucla.edu/FacultyPages/Hays/util.htm Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 generate a particular sequence ?
Sorry. It was my typo. Should be three times as it in the example. Feng On Mon, Sep 13, 2010 at 11:32 AM, Jim Lemon j...@bitwrit.com.au wrote: On 09/13/2010 07:19 PM, Feng Li wrote: Dear R, I have a vector, say a = c(1,2,4,5,6,8). Can I generate a vector or array (2-by-3-by-3) of this form c(1,2,1,2,1,2,4,5,4,5,4,5,6,8,6,8,6,8), in which every two elements in a have been repeated twice? I am to stupid today and could not figure this simple question out... Many many thanks! Hi Feng, I would take a quick look at the help for rep and c, but I would first suggest that you count the number of times that the elements are to be repeated. While you have made the definition of the problem reasonably clear with your example, there are an awful lot of combinations of every two elements of a, whether you want to repeat them two or three times. Jim -- Feng Li Department of Statistics Stockholm University 106 91 Stockholm, Sweden http://feng.li/ [[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] Line integral with R
Hello. I would like to calculate with R the weighted line integral of a loss field. Where should I start searching about weighted integration in R? I would like to thank you in advance for your help Best Regards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to generate a particular sequence ?
Thanks. That's what I want. Sorry for the typo:) Feng On Mon, Sep 13, 2010 at 11:42 AM, Ted Harding ted.hard...@manchester.ac.ukwrote: On 13-Sep-10 09:19:21, Feng Li wrote: Dear R, I have a vector, say a = c(1,2,4,5,6,8). Can I generate a vector or array (2-by-3-by-3) of this form c(1,2,1,2,1,2,4,5,4,5,4,5,6,8,6,8,6,8) in which every two elements in a have been repeated twice? I am to stupid today and could not figure this simple question out... Many many thanks! Feng A possible solution (somewhat generalisable): a - c(1,2,4,5,6,8) Reps - 3 pairs - matrix(a,nrow=2) as.vector(pairs[,rep(c(1,2,3),each=Reps)]) # [1] 1 2 1 2 1 2 4 5 4 5 4 5 6 8 6 8 6 8 (By the way, you have 3 repetitions but wrote twice -- I assume you meant thrice but the above generalises to 2 repetitions ... :) Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 13-Sep-10 Time: 10:42:46 -- XFMail -- -- Feng Li Department of Statistics Stockholm University 106 91 Stockholm, Sweden http://feng.li/ [[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] Need to have more control on cat()
Hi all, here is my small piece of codes: fn1 - function(x = 4) { y - 0 if(y == 0) cat(y value is zero\n) # I intentionally created 2nd line here return(4) } If I run this function I get following fn1() y value is zero [1] 4 Here you see there are lot of spaces before is zero. How can I format cat() to force it to start from margin? Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SF-36 questionnaire scoring for R?
On Mon, Sep 13, 2010 at 11:16 AM, Dieter Menne dieter.me...@menne-biomed.de wrote: Dear useRs from the physiology department, Does someone know of an implementation of the SF-36 questionnaire scoring in R? I only found SAS and STATA versions, e.g http://gim.med.ucla.edu/FacultyPages/Hays/util.htm I do love SAS code for a good chuckle on a wet Monday morning... http://gim.med.ucla.edu/FacultyPages/Hays/UTILS/SF36/sf36.sas * SAS CODE FOR SCORING 36-ITEM HEALTH SURVEY 1.0 * WRITTEN BY RON D. HAYS, RAND, 310-393-0411 (EXT. 7581) ***; DATA TEMP1; SET TEMP; RENAME I1=I1 I2=I2 I3=I3 I4=I4 I5=I5 I6=I6 I7=I7 I8=I8 I9=I9 I10=I10 I11=I11 I12=I12 I13=I13 I14=I14 I15=I15 I16=I16 I17=I17 [etc etc] The rest of it appears to be pages and pages of nested IF- statements which could be translated into R fairly easily, but without a test set (and currently ROFL'ing over those first 40 lines) I can't attempt. Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need to have more control on cat()
On Mon, Sep 13, 2010 at 11:53 AM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hi all, here is my small piece of codes: fn1 - function(x = 4) { y - 0 if(y == 0) cat(y value is zero\n) # I intentionally created 2nd line here return(4) } If I run this function I get following fn1() y value is zero [1] 4 Here you see there are lot of spaces before is zero. How can I format cat() to force it to start from margin? Don't indent it? This isn't Python, you know. if(y==0){cat(y value is zero\n) } should work, producing y value is zero is that what you want? Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need to have more control on cat()
Thanks Barry, I agree it will work. But this approach destroys the indent in the program body therefore entire body of program looks messy, for example cat(Here I put indent) obviously looks better for someone who reads my code, than cat(Here I dont put indent) Any better approach? On Mon, Sep 13, 2010 at 4:30 PM, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Mon, Sep 13, 2010 at 11:53 AM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hi all, here is my small piece of codes: fn1 - function(x = 4) { y - 0 if(y == 0) cat(y value is zero\n) # I intentionally created 2nd line here return(4) } If I run this function I get following fn1() y value is zero [1] 4 Here you see there are lot of spaces before is zero. How can I format cat() to force it to start from margin? Don't indent it? This isn't Python, you know. if(y==0){cat(y value is zero\n) } should work, producing y value is zero is that what you want? Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saveing plot to multiple locations
On 09/13/2010 11:32 AM, Joel wrote: Hi Im trying to save a plot both to a pdf and as just a picture but without success so if someone can help me I would be happy :) The problem is that the plot goes only to one graphics device, the last one you defined. Just make the plot twice: pdf(bla.pdf) plot(bla) dev.off() png(bla.png) plot(bla) dev.off() cheers, Paul my code: require(party) irisct- ctree(Species ~ .,data = iris) data(iris) attach(iris) pdf('/home/joel/Skrivbord/mammamu.pdf') try(png('/home/joel/Skrivbord/mammamu1.png')) plot(Sepal.Length, Petal.Length, col=unclass(Species)) legend(4.5, 7, levels(Species), col=plot_colors, cex=0.8, fill=1:3) try(png('/home/joel/Skrivbord/mammamu2.png')) plot(irisct) dev.off() readBin(pic,'raw',1024*1024) readBin('/home/joel/Skrivbord/mammamu2.png','raw',1024*1024) Ive tryed to move around the png and pdf part to see if it worked better if they where in an other order but as I said without success. //Joel -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 253 5773 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need to have more control on cat()
On Mon, Sep 13, 2010 at 12:11 PM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Thanks Barry, I agree it will work. But this approach destroys the indent in the program body therefore entire body of program looks messy, for example cat(Here I put indent) obviously looks better for someone who reads my code, than cat(Here I dont put indent) Any better approach? Something like: cat(Here I\n, have some indented source\n, which doesn't output indented.,sep=) Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SF-8 (not 36) questionnaire scoring for R?
Barry Rowlingson wrote: * SAS CODE FOR SCORING 36-ITEM HEALTH SURVEY 1.0 ... Thanks, Barry, but there was a mistake from my side: I am looking for SF-8. Anyone else? Google was not successful for me Dieter -- View this message in context: http://r.789695.n4.nabble.com/SF-36-questionnaire-scoring-for-R-tp2537198p2537261.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] Adding dummy variable zero/one in ARIMA model in R
Dear R gurus, How do I add dummy variable zero/ one in the ARIMA model both in the in-sample and outside the sample(forecasts)? Regards Peter South Africa Tell: +2712 422 7357 Please Note: This email and its contents are subject to our email legal notice which can be viewed at http://www.sars.gov.za/Email_Disclaimer.pdf [[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] sum to infinity
hello, can i calculate a sum to infinity in R. i want to do something like this: \sum_{i=0}^\infty \frac{2^{-d-1}}{\Gamma(\frac{d-1}{2})}\left(\frac{\Gamma(2d-3)(2-d)_{i}\Gamma(i+1,-z/2)2^{i+1}}{\Gamma(d-1)(4-2d)_{i}i!}\right)+ \\ \sum_{i=0}^\infty \frac{2^{-d-1}}{\Gamma(\frac{d-1}{2})}\left(\frac{\Gamma(3-2d)(d-1)_{i}\Gamma(2d-2+i,-z/2)2^{2d-2+i}}{\Gamma(2-d)(2d-2)_{i}}\right), where (a)_{i}=\Gamma(a+i) / \Gamma(a) . I hope someone can help me. Tuggi -- View this message in context: http://r.789695.n4.nabble.com/sum-to-infinity-tp2537122p2537122.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 with ugarchspec function
Hi I am using the ugarchspec function from the rgarch package to fit a mean variance model jointly. Following is the code I'm using: spec = ugarchspec(variance.model = list(model=eGARCH, garchOrder=c(1,1)), mean.model = list(armaOrder=c(1,1))) On doing this, I get the following error: Error in ugarchspec(variance.model = list(model = eGARCH, garchOrder = c(1, : could not find function .DistributionBounds Any help on why this is happening? any way to solve this? Thanks Priyesh [[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] Block other mails
Dear Sir or Madam, I was trying to log back on to change my details, I want to stop receiving other user's problems/solutions into my inbox. Yours sincerely, Charlotte Ndiribe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Overlay of two graphs of different axes
On Sep 13, 2010, at 1:54 AM, Uwe Dippel wrote: Though I have read quite a bit, and tried quite a bit, I have yet to find a nice way to overlay 2 or more curves in the same plot, with different ranges. The different axes could be a problem but if you construct both with predefined coordinates systems and scale appropriately it should work out. See the twoord.plot function in plotrix. Here is simplified sample code to demonstrate the question: plot(2*(seq(1,5)), type=l, axes=FALSE) ? lines lines(1.5*(seq(2,5)), type=b) curve(2*(seq(1,5)), type=b, add=TRUE) Error in curve(2 * (seq(1, 5)), type = b, add = TRUE) : 'expr' must be a function or an expression containing 'x' axis(2) curve(x^2, 1, 5, type=b, add=TRUE) axis(4) Firstly, as an aside, I am not clear why 'curve' has a different syntax compared to 'plot'. As a still beginner, I'd for one would be happy to add curves to a plot; curves of just different parameters. Though, I guess, there must be a good reason? curve is like abline in that it draws from left x range to right x range. Mostly, however, I wonder how to plot a number of curves into an original plot, that re-defines the min/max from the most recent curve. lines() or segments() In the example that I constructed, axis(2) does exactly the expected thing. What I want to do next, though, with the least effort, is to add another function in a manner that the added function is scaled, not according to the first function (plot), but to fit into the plotting area. (The example above overshoots the range). Plus, how can I subsequently add the axis suitable to the most recent function? That is, how can I render axis(4) to displaying the scale for the second graph, created with 'curve'? There are many worked examples in the archives, as well as canned solutions in widely used packages. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Create a time-series from cross-sectional data that has each year as a separate column
On Sep 13, 2010, at 2:31 AM, Gabriel Bergin wrote: Hi, I have a dataset from ILO, originally in csv-format, that I have read into R. It is cross-sectional time-series data, so I have a bunch of variables and dummy variables that I need to extract data from for the entire time period. However, the years are separated by columns instead of rows, as is usually the case in R. This is what it looks like: str(laborstafinMFBA) 'data.frame': 152 obs. of 39 variables: $ COUNTRY: Factor w/ 164 levels Albania,Algeria,..: 2 4 7 8 9 10 11 11 12 13 ... $ CODE.COUNTRY : Factor w/ 163 levels AE,AG,AI,..: 44 7 8 5 12 11 10 10 13 23 ... $ SOURCE : Factor w/ 7 levels Administrative reports,..: 3 3 3 3 3 3 3 3 3 3 ... $ CODE.SOURCE: Factor w/ 7 levels A,B,BA,CA,..: 3 3 3 3 3 3 3 3 3 3 ... etc.. $ D1990 : num NA NA NA NA NA ... $ D1991 : num NA NA 101 NA NA ... $ D1992 : num NA 38.4 111.2 NA NA ... $ D1993 : num NA NA 94.4 NA NA ... $ D1994 : num NA NA 133.69 NA 1.42 ... $ D1995 : num NA NA 121 NA NA ... $ D1996 : num NA NA 176 NA NA ... $ D1997 : num NA NA 195.31 NA 1.51 ... $ D1998 : num NA NA 202 NA NA ... $ D1999 : num NA NA 201 NA NA ... $ D2000 : num NA NA 207 NA NA ... $ D2001 : num 68.1 NA 198.3 NA NA ... $ D2002 : num NA NA 186 NA NA ... $ D2003 : num 67.6 NA 148.8 NA NA ... $ D2004 : num 68.8 NA 143.7 NA NA ... $ D2005 : num NA NA 163 NA NA ... $ D2006 : num NA NA 189 NA NA ... $ D2007 : num NA NA NA 14 1.91 ... How do I transform this into something that I can make a time-series of? ?reshape package reshape(not the same as the function reshape) package sqldf There might also be the possibility of using t() on just the Dyear columns but it might not give desired results on the association of COUNTRY with SOURCE It looks as though there are a mixture of data types and that you might want to pull out all the types of SOURCE separately before transforming or go to a database-oriented solution. Sincerely, Gabriel Bergin gabr...@bergin.se [[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 West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saveing plot to multiple locations
On Sep 13, 2010, at 5:32 AM, Joel wrote: Hi Im trying to save a plot both to a pdf and as just a picture but without success so if someone can help me I would be happy :) Are you trying to embed a png file in a graphic or do you just want two different files? If the first (obviously the more difficult) then Paul Murrell has a bunch of material he has offered over the years: cran.r-project.org/web/packages/grImport/vignettes/import.pdf Vector graphics is the focus but citations to packages handling raster or bitmap graphics are included. If it is the second, then just do one task, complete it with dev.off(), which is needed to close the file, and move on to the other. -- David my code: require(party) irisct - ctree(Species ~ .,data = iris) data(iris) attach(iris) pdf('/home/joel/Skrivbord/mammamu.pdf') try(png('/home/joel/Skrivbord/mammamu1.png')) plot(Sepal.Length, Petal.Length, col=unclass(Species)) legend(4.5, 7, levels(Species), col=plot_colors, cex=0.8, fill=1:3) try(png('/home/joel/Skrivbord/mammamu2.png')) plot(irisct) dev.off() readBin(pic,'raw',1024*1024) readBin('/home/joel/Skrivbord/mammamu2.png','raw',1024*1024) Ive tryed to move around the png and pdf part to see if it worked better if they where in an other order but as I said without success. //Joel -- View this message in context: http://r.789695.n4.nabble.com/Saveing-plot-to-multiple-locations-tp2537133p2537133.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. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] print matrix values and if statement
Hello everyone, I have a 2x2 matrix filled with zeros and some more values around zeros. I would like to print only the non-zero values and to keep the coords of the places that the values are not zero. Could you please help me with that? I would like to thank you in advance for your help Best Regards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] shade area between 'ablines'
Hi, want to shade the area between dotted lines: x=c(1,5);y=c(1,5) plot(y~x, type='n') abline(v=c(2,3), lty=2) sometnig simple needed. tried with polygon thx, robert -- View this message in context: http://r.789695.n4.nabble.com/shade-area-between-ablines-tp2537352p2537352.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] lattice: Set x-axis in italics only
Dear list, I making some box-and-whisker plots in R with vertebrate data. The x axis are species names that must be in italics. I tried with the axis function but no luck, and it seems that affects both axes. Any tip? Thanks a lot in Advance. Alej __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] shade area between 'ablines'
Try this getting the limits of the plot area: x=c(1,5);y=c(1,5) plot(y~x, type='n') abline(v=c(2,3), lty=2) usr - par('usr') usr [1] 0.84 5.16 0.84 5.16 rect(2, usr[3], 3, usr[4], col='green') On Mon, Sep 13, 2010 at 8:45 AM, threshold r.kozar...@gmail.com wrote: Hi, want to shade the area between dotted lines: x=c(1,5);y=c(1,5) plot(y~x, type='n') abline(v=c(2,3), lty=2) sometnig simple needed. tried with polygon thx, robert -- View this message in context: http://r.789695.n4.nabble.com/shade-area-between-ablines-tp2537352p2537352.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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] print matrix values and if statement
Here is how to get the indices of the non-zero values. You can determine how you want to print them x - rbind(c(1,0), c(0,3)) # get indices of non-zero which(x != 0, arr.ind=TRUE) row col [1,] 1 1 [2,] 2 2 possible ways of printing: x.1[x.1 == 0] - NA x.1 [,1] [,2] [1,]1 NA [2,] NA3 print(x.1, na.print='.') [,1] [,2] [1,]1. [2,].3 On Mon, Sep 13, 2010 at 7:44 AM, Alaios ala...@yahoo.com wrote: Hello everyone, I have a 2x2 matrix filled with zeros and some more values around zeros. I would like to print only the non-zero values and to keep the coords of the places that the values are not zero. Could you please help me with that? I would like to thank you in advance for your help Best Regards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] problems with siar package
Please report to the siar package maintainer (including the package version of siar you are using). Best, Uwe Ligges On 08.09.2010 00:36, Julio Lucio Lancelotti wrote: Hi, my name is Julio, I'm trying to run a script, specifically with the siar package on R (I have attached the script) but the program collapses on during the run. The error message says: *** caught segfault *** address 0xb31941cc, cause 'memory not mapped' Traceback: 1: .C(siarmcmcv4, as.integer(numdata), as.integer(numsources), as.integer(numiso), as.integer(numgroups), as.integer(startgroup), as.integer(endgroup), as.integer(siardata$iterations), as.integer(siardata$burnin), as.integer(siardata$howmany), as.integer(siardata$thinby), as.double(prior), as.data.frame(data2), as.data.frame(concdepdata), as.data.frame(sourcedata), as.data.frame(correctionsdata), as.data.frame(parameters)) 2: siarmcmcdirichletv4(target, source, fraction, iterations = 5e+05, burnin = 1e+05, howmany = 2000, thinby = 10) Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: 0xa6737790 'memory not mapped' I'm using the library “siar”, specifically the function: siarmcmcdirichletv4 #___ However if I choose option 1 all results are saved, even those generated during the failure Additional information: R version 2.11.1 (2010-05-31) OS: 10.04 LTS, i686 GNU/Linux Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem after repackaging
On 28.08.2010 11:07, Samy Khezami wrote: Hy, I had a mistake on a function of a package i have created! I have solved it and then i repackaged and installed the modified package. Probably you installed the modified package into a diferent location from the location that is used in Excel. Uwe Ligges I use to launch R from Excel! And so when i launch R, and next call my function from the workspace, i still find the problem on my function. And when i read on my workspace, the source code of my function, i find the old version of my function (the one from the precedent version of my package)! If one of you have ever met this kind of problem, could you help me. Thanks Samy Khezami M.S. Quantitative Finance EM Lyon Business School 0033625430829 samy-khezami@em-lyon.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] Saveing plot to multiple locations
Thx for all the help! Dave: Its the second ones so now it looks like this and works but its abit ugly as you have to plot the same thing two times but dossent seem to be any other way or? try(png('/home/joel/Skrivbord/mammamu2.png')) plot(irisct) dev.off() pdf('/home/joel/Skrivbord/mammamu.pdf') plot(irisct) dev.off() -- View this message in context: http://r.789695.n4.nabble.com/Saveing-plot-to-multiple-locations-tp2537133p2537402.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SF-8 (not 36) questionnaire scoring for R?
I know someone who has R code for SF-36 and perhaps SF-12. Aren't there copyright issues relating to SF-* even if it is reprogrammed? Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/SF-36-questionnaire-scoring-for-R-tp2537198p2537404.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SF-8 (not 36) questionnaire scoring for R?
On Sep 13, 2010, at 8:13 AM, Frank Harrell wrote: I know someone who has R code for SF-36 and perhaps SF-12. Aren't there copyright issues relating to SF-* even if it is reprogrammed? Frank Yep... http://www.qualitymetric.com/RequestInformation/SurveyInformationRequestDemo/tabid/263/Default.aspx HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lattice: Set x-axis in italics only
Hi You may need to investigate ?plotmath and ?expression for the italics or possibly add a font=... somewhere Sorry cannot be more help it is too late here Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email home: mac...@northnet.com.au At 22:50 13/09/2010, you wrote: Dear list, I making some box-and-whisker plots in R with vertebrate data. The x axis are species names that must be in italics. I tried with the axis function but no luck, and it seems that affects both axes. Any tip? Thanks a lot in Advance. Alej __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 elements from list: Is [[ always faster than $ ??
Yes: $() has to calculate more on matching the names --- and is more of a hack anyway. Although, I would not worry to much about 0.3 seconds in 100 evaluations ... Uwe On 08.09.2010 14:31, Søren Højsgaard wrote: Dear list It seems to me that extracting elements from a list using '[[' is somewhat faster than using '$'. For example: x- as.list(1:25) names(x)- letters[1:length(x)] dput(x) structure(list(a = 1L, b = 2L, c = 3L, d = 4L, e = 5L, f = 6L, g = 7L, h = 8L, i = 9L, j = 10L, k = 11L, l = 12L, m = 13L, n = 14L, o = 15L, p = 16L, q = 17L, r = 18L, s = 19L, t = 20L, u = 21L, v = 22L, w = 23L, x = 24L, y = 25L), .Names = c(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y)) system.time({ for (ii in 1:100) x[[21]] }) user system elapsed 0.550.000.54 system.time({ for (ii in 1:100) x[[u]]}) user system elapsed 0.840.000.84 system.time({ for (ii in 1:100) x$u}) user system elapsed 1.120.001.13 Does anyone know if this is always the case? (I have not found anything about speed in this connection on the help pages, apologies if I have overlooked something). I use R.2.11.1 on Windows 7. Regards __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] working version r-2.11.1-win 32.exe
Dear authors! Could you specify the WEB page on which there is a working version of R-2.11.1 for windows vista 32, of 10 I have received files from different servers all were broken. The problem with the file itself r-2.11.1-win 32.exe, as the program for linux from the same websites will download and unzip fine. I hope for your help. Dr. Pavel Sorokin. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] working version r-2.11.1-win 32.exe
On 13.09.2010 14:30, Molecular Diagnostic Center IPEE RAS wrote: Dear authors! Could you specify the WEB page on which there is a working version of R-2.11.1 for windows vista 32, of 10 I have received files from different servers all were broken. The problem with the file itself r-2.11.1-win 32.exe, as the program for linux from the same websites will download and unzip fine. I hope for your help. It works from any CRAN mirror I tried. The file is called R-2.11.1-win32.exe by the way and available from CRAN MIRROR/bin/windows/base/release.htm . Try to compare the md5 checksum in order to find out if your download is broken (e.g. due to local connectivity problems). Uwe Ligges Dr. Pavel Sorokin. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SF-8 (not 36) questionnaire scoring for R?
Frank Harrell wrote: I know someone who has R code for SF-36 and perhaps SF-12. Aren't there copyright issues relating to SF-* even if it is reprogrammed? You are right. I was not aware of this, and I could not believe it first that a company holds the right to use an almost trivial algorithm. (BTW: I just heard from a colleague they needed SIX month to send a quotation.) Dieter -- View this message in context: http://r.789695.n4.nabble.com/SF-36-questionnaire-scoring-for-R-tp2537198p2537437.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] array of objects
Hello everyone. I would like to create some agents that span over a specific area map.Every agent needs to have its own data structures like one or two matrices and one list. I think that the best way to do this is to create objects and every instance of an object will be used for a single agent. The number of agents is not predetermined and it varies for any execution. So I read this value from the command line interface and then I would like to initiate so many objects as the agents. I think that the best way to do that is to create using a for loop a list containing as many objects as the agents are. Is it possible to help me do that with R... the tricky part is not only to create these objects but also having some nice way to address them... Perhaps an index i might be used for that. I would like to thank you in advance for your help Best Regards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] shade area between 'ablines'
Thanks for replying, indeed works. I forgot to mention that I am looking for a 'transparent shading' s.t. the plot symbols are still visible on the shaded area. robert -- View this message in context: http://r.789695.n4.nabble.com/shade-area-between-ablines-tp2537352p2537479.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SF-8 (not 36) questionnaire scoring for R?
Yes the company behind that probably received federal funds for some of the research and has been very careful to minimize their contribution to the community. I didn't understand your parenthetical remark. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/SF-36-questionnaire-scoring-for-R-tp2537198p2537480.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SF-8 (not 36) questionnaire scoring for R?
If it's not possible to use their particular algorithms, does anyone think it would be helpful/practical to try to write a general scoring system? I imagine a function with arguments for column names, a list where each element is a vector that indicates the numbers that correspond to various subscales, an argument that could handle any reverse scoring, etc. I am willing to have a go at this if people think it would be worthwhile (read: if someone wiser than me thinks it is not a waste of time). Josh On Mon, Sep 13, 2010 at 6:19 AM, Marc Schwartz marc_schwa...@me.com wrote: On Sep 13, 2010, at 8:13 AM, Frank Harrell wrote: I know someone who has R code for SF-36 and perhaps SF-12. Aren't there copyright issues relating to SF-* even if it is reprogrammed? Frank Yep... http://www.qualitymetric.com/RequestInformation/SurveyInformationRequestDemo/tabid/263/Default.aspx HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lattice: Set x-axis in italics only
On Sep 13, 2010, at 8:50 AM, Alejo C.S. wrote: Dear list, I making some box-and-whisker plots in R with vertebrate data. The x axis are species names that must be in italics. I tried with the axis function but no luck, and it seems that affects both axes. Any tip? In bwplot just add: ..., scales=list(x=list(font=3)), In this case (and I suppose many others) lattice is much more flexible than base. I initially tried what appeared to be valid strategies with boxplot and ended up tied in knots. Then I noticed your subject line and it was trivial. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help on simple problem with optim
Did you check if the data in da has any NA in the dependent or the independent data? Remember that your function llk.mar is going to evaluate dnorm for each pair. If any of those pairs has an NA value, your function will return an NA at the end (sum(c(NA,1,2,3)) = NA) I would check if the llk.mar function is fine for the whole domain of your data. My suggestion is to add an if right before llk-sum(dnorm), where you evaluate for NAs in that vector. If you find one, get rid of it before returning the function!. Try that before optim, then let it do the solving. Cheers, Cristián Montes. -Mensaje original- De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] En nombre de Zhang,Yanwei Enviado el: Jueves, 09 de Septiembre de 2010 02:54 p.m. Para: r-help@r-project.org Asunto: [R] Help on simple problem with optim Dear all, I ran into problems with the function optim when I tried to do an mle estimation of a simple lognormal regression. Some warning message poped up saying NANs have been produced in the optimization process. But I could not figure out which part of my code has caused this. I wonder if anybody would help. The code is in the following and the data is in the attachment. da - read.table(da.txt,header=TRUE) # fit with linear regression using log transformation of the response variable fit - lm(log(yp) ~ as.factor(ay)+as.factor(lag),data=da) # define the log likelihood to be maximized over llk.mar - function(parm,y,x){ # parm is the vector of parameters # the last element is sigma # y is the response # x is the design matrix l - length(parm) beta - parm[-l] sigma - parm[l] x - as.matrix(x) mu - x %*% beta llk - sum(dnorm(y, mu, sigma,log=TRUE)) return(llk) } # initial values parm - c(as.vector(coef(fit)),summary(fit)$sigma) y - log(da$yp) x - model.matrix(fit) op - optim(parm, llk.mar, y=y,x=x,control=list(fnscale=-1,maxit=10)) After running the above code, I got the warning message: Warning messages: 1: In dnorm(x, mean, sd, log) : NaNs produced 2: In dnorm(x, mean, sd, log) : NaNs produced I would really appreciate if anybody would help to point out the problem with this code or tell me how to trace it down (using trace?)? Many thanks in advance. Wayne (Yanwei) Zhang Statistical Research CNA NOTICE: This e-mail message, including any attachments and appended messages, is for the sole use of the intended recipients and may contain confidential and legally privileged information. If you are not the intended recipient, any review, dissemination, distribution, copying, storage or other use of all or any portion of this message is strictly prohibited. If you received this message in error, please immediately notify the sender by reply e-mail and delete this message in its entirety. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] confidence bands for a quasipoisson glm
On Sat, 2010-09-11 at 14:41 -0700, Peng, C wrote: Is this something you want to have (based on a simulated dataset)? counts - c(18,17,15,20,10,20,25,13,12) #risk - round(rexp(9,0.5),3) risk- c(2.242, 0.113, 1.480, 0.913, 5.795, 0.170, 0.846, 5.240, 0.648) gm - glm(counts ~ risk, family=quasipoisson) summary(gm) new.risk=seq(min(risk), max(risk),0.1) new.risk y - predict.glm(gm, newdata=data.frame(risk=new.risk), se.fit=TRUE, type=response) I think you should be doing this bit on the scale of the link function, not the response, and then transform. y - predict.glm(gm, newdata=data.frame(risk=new.risk), se.fit=TRUE, type=link) upper=y$fit+1.96*y$se.fit lower=y$fit-1.96*y$se.fit upper - with(y, exp(fit + (2 * se.fit))) lower - with(y, exp(fit - (2 * se.fit))) fit - with(y, exp(fit)) plot(new.risk, fit, type=l, col=4, lty=1, lwd=2, ylim = range(c(upper, lower))) lines(new.risk, upper, type=l, col=2, lty=2, lwd=2) lines(new.risk, lower, type=l, col=2, lty=2, lwd=2) plot(new.risk,y$fit, type=l, col=4, lty=1, lwd=2) lines(new.risk, upper, type=l, col=2, lty=2, lwd=2) lines(new.risk, lower, type=l, col=2, lty=2, lwd=2) HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Axis break with gap.plot()
Hi again everyone. Anyone know if there's any limitation with gap.plot concerning the fill color of plotted markers? I would like to fill the circles with a color : library(plotrix); gap.plot(c(1,2,3,4,10), c(1,2,3,4,10), c(5,9), pch = 21, col = red); However, it only change the color of the line. I tried bgcol and some argument but without success. With regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/Axis-break-with-gap-plot-tp2533027p2537540.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] shade area between 'ablines'
check out this link http://finzi.psych.upenn.edu/R/library/seqinr/html/col2alpha.html On Mon, Sep 13, 2010 at 9:58 AM, threshold r.kozar...@gmail.com wrote: Thanks for replying, indeed works. I forgot to mention that I am looking for a 'transparent shading' s.t. the plot symbols are still visible on the shaded area. robert -- View this message in context: http://r.789695.n4.nabble.com/shade-area-between-ablines-tp2537352p2537479.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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] shade area between 'ablines'
Hi: Here's a ggplot2 example: p - ggplot(mtcars, aes(x = wt, y = mpg)) p + geom_rect(xmin = 2, xmax = 3, ymin = 0, ymax = Inf, fill = 'green', alpha = 0.2) + geom_point() + theme_bw() I don't know why the alpha transparency doesn't work in this example, but plotting the points after shading the rectangle at least makes the points visible. HTH, Dennis On Mon, Sep 13, 2010 at 6:58 AM, threshold r.kozar...@gmail.com wrote: Thanks for replying, indeed works. I forgot to mention that I am looking for a 'transparent shading' s.t. the plot symbols are still visible on the shaded area. robert -- View this message in context: http://r.789695.n4.nabble.com/shade-area-between-ablines-tp2537352p2537479.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.
Re: [R] Axis break with gap.plot()
On Sep 13, 2010, at 10:34 AM, Filoche wrote: Hi again everyone. Anyone know if there's any limitation with gap.plot concerning the fill color of plotted markers? I would like to fill the circles with a color : library(plotrix); gap.plot(c(1,2,3,4,10), c(1,2,3,4,10), c(5,9), pch = 21, col = red); However, it only change the color of the line. I tried bgcol and some argument but without success. Change pch to 19. (=solid circle) With regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/Axis-break-with-gap-plot-tp2533027p2537540.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. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving/loading custom R scripts
I'm still relatively new to R, so I tried the first of you two solutions: .First - function(){ source(Friedman-Test-with-Post-Hoc.r.txt) } Thanks very much for that, it works perfectly Cheers -- View this message in context: http://r.789695.n4.nabble.com/Saving-loading-custom-R-scripts-tp2530924p2537547.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SF-8 (not 36) questionnaire scoring for R?
On Sep 13, 2010, at 8:59 AM, Joshua Wiley wrote: If it's not possible to use their particular algorithms, does anyone think it would be helpful/practical to try to write a general scoring system? I imagine a function with arguments for column names, a list where each element is a vector that indicates the numbers that correspond to various subscales, an argument that could handle any reverse scoring, etc. I am willing to have a go at this if people think it would be worthwhile (read: if someone wiser than me thinks it is not a waste of time). Josh It's not clear to me what you are proposing. The SF-* instruments are validated scoring systems, that have been demonstrated to correlate to quality of life and in turn, to healthcare resource utilization and cost. Are you proposing to develop an algorithm that performs the same set of functions? If so, note that you would have to go through the same scoring system validation that originally RAND and now QualityMetric have gone through. Of course, you could use RAND's original implementation of the SF-36 (RAND-36): http://www.rand.org/health/surveys_tools/mos/mos_core_36item.html which is in the public domain. However, there are material differences in the scoring systems now used by QM and the original RAND scoring mechanism, as I understand it, is almost never used these days. Regards, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lattice: Set x-axis in italics only
Hi: demo(graphics) has a lot of nice examples of how to use various features - one of them is font selection. font = 3 = italic font = 4 = bold italic You need to select the correct aspect of the plot, however: font.main, font.sub, font.lab or font.axis (from par()). HTH, Dennis On Mon, Sep 13, 2010 at 5:50 AM, Alejo C.S. alej@gmail.com wrote: Dear list, I making some box-and-whisker plots in R with vertebrate data. The x axis are species names that must be in italics. I tried with the axis function but no luck, and it seems that affects both axes. Any tip? Thanks a lot in Advance. Alej __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SF-8 (not 36) questionnaire scoring for R?
On Sep 13, 2010, at 15:59 , Joshua Wiley wrote: If it's not possible to use their particular algorithms, does anyone think it would be helpful/practical to try to write a general scoring system? I imagine a function with arguments for column names, a list where each element is a vector that indicates the numbers that correspond to various subscales, an argument that could handle any reverse scoring, etc. I am willing to have a go at this if people think it would be worthwhile (read: if someone wiser than me thinks it is not a waste of time). I don't think that's the issue at all. It is a matter of being able to say that you did it The Standard Way (i.e. their way, by the book/manual) or not. It really doesn't matter how trivial the procedure is, or even whether it is the right thing to do. Even if you do a complete clean-room implementation of their scoring system, they can claim either that what you do is not SF-36 or if you say that it is, that you owe them money. Josh On Mon, Sep 13, 2010 at 6:19 AM, Marc Schwartz marc_schwa...@me.com wrote: On Sep 13, 2010, at 8:13 AM, Frank Harrell wrote: I know someone who has R code for SF-36 and perhaps SF-12. Aren't there copyright issues relating to SF-* even if it is reprogrammed? Frank Yep... http://www.qualitymetric.com/RequestInformation/SurveyInformationRequestDemo/tabid/263/Default.aspx HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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. -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting multiple edges with iGraph
Thanks Gábor! -- View this message in context: http://r.789695.n4.nabble.com/Plotting-multiple-edges-with-iGraph-tp2527506p2537603.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] Problems with reshape2 on Mac
Hi! I updated to reshape2 yesterday and tried to make it work. Unfortunately, it mainly throws error messages at me (good thing it's reshape2 1.0 and not reshape 2.0). The most recent is: Error in match.fun(FUN) : object 'id' not found When I manually create an object 'id', it says: Error in get(as.character(FUN), mode = function, envir = envir) : object 'id' of mode 'function' was not found I assume that dcast is looking for a function by the name 'id' which is not present. I tried both Rdaemon within TextMate and R in the Terminal. I also tried both my own code and the airquality example. reshape is still working flawlessly. I also needed to load plyr manually to make another error message go away, that asked for 'as.quoted'. Best, Paul --- Paul Metzner Humboldt-Universität zu Berlin Philosophische Fakultät II Institut für deutsche Sprache und Linguistik Post: Unter den Linden 6 | 10099 Berlin | Deutschland Besuch: Dorotheenstraße 24 | 10117 Berlin | Deutschland +49-(0)30-2093-9726 paul.metz...@rz.hu-berlin.de http://amor.rz.hu-berlin.de/~metznerp/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Specify a minimum number of valid arguments for the mean function
Hello all, I want to specify a minimum number of valid arguments for the mean function--I have 5 variables but I want the mean only of cases that have at least 3 valid answers. What is the best way to do that? Thank you very much! Luana [[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] Sample a vector repeatedly
Id like to sample the vector y repeatedly. In this dummy dataset, Id like to sample (and store) it 1, 2, and 3 times. Is there a straightforward way to do this without using a for loop? x - c(1 :3) y - c(1:10) (run.sample - sample (y, x)) Thanks very much, James Hudson [[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] Axis break with gap.plot()
Thank you sir. Regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/Axis-break-with-gap-plot-tp2533027p2537660.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] as.Date() add a day to a date
I'm trying to understand why as.Date() is converting a the modified date of a file from August 22 to August 23. foo - file.info(file.to.process) str(foo) 'data.frame': 1 obs. of 10 variables: $ size : num 5.37e+09 $ isdir : logi FALSE $ mode :Class 'octmode' int 436 $ mtime : POSIXct, format: 2010-08-22 23:14:52 $ ctime : POSIXct, format: 2010-09-13 11:34:31 $ atime : POSIXct, format: 2010-09-09 15:42:00 $ uid : int 503 $ gid : int 503 $ uname : chr ayee $ grname: chr ayee as.Date(foo$mtime) [1] 2010-08-23 In this case as.Date(foo$mtime) gives August 23. I would have expected August 22. Thanks, Andrew sessionInfo() R version 2.11.1 Patched (2010-09-11 r52901) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[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] SF-8 (not 36) questionnaire scoring for R?
On Mon, Sep 13, 2010 at 8:02 AM, Marc Schwartz marc_schwa...@me.com wrote: On Sep 13, 2010, at 8:59 AM, Joshua Wiley wrote: If it's not possible to use their particular algorithms, does anyone think it would be helpful/practical to try to write a general scoring system? I imagine a function with arguments for column names, a list where each element is a vector that indicates the numbers that correspond to various subscales, an argument that could handle any reverse scoring, etc. I am willing to have a go at this if people think it would be worthwhile (read: if someone wiser than me thinks it is not a waste of time). Josh It's not clear to me what you are proposing. The SF-* instruments are validated scoring systems, that have been demonstrated to correlate to quality of life and in turn, to healthcare resource utilization and cost. Are you proposing to develop an algorithm that performs the same set of functions? If so, note that you would have to go through the same scoring system validation that originally RAND and now QualityMetric have gone through. Apologies on not being clearer, I certainly did not mean develop and validate an alternate scoring system for the SF-*. I was thinking many scales have steps in common (like overall vs. subscale scores, reverse coding, z-scoring items, weighting items by difficulty), and that this could be automated in a function. Ideally, once these initial steps were done, the user would have little left to do to score it. I can think of a few scales in psychology where the subscales are essentially just summed (after appropriate reversing and scaling). This pseudo-code is an example of what I was thinking function(dataset = mydata, variables = colnames(mydata)[1:20], reverse.code = c(3, 6, 8, 12, 14), subscales = list(A = c(1:6, 11:14), B = c(7:10, 15:20)), scale = TRUE/FALSE, weights = , algorithm = ) But, the more I think about it, the first part is trivial to implement, and in the case where scoring is more complex, users are not just going to be able to pass one line of code to the mystical algorithm argument and be done, which answers my question whether it would be useful. Sincerely, Josh Of course, you could use RAND's original implementation of the SF-36 (RAND-36): http://www.rand.org/health/surveys_tools/mos/mos_core_36item.html which is in the public domain. However, there are material differences in the scoring systems now used by QM and the original RAND scoring mechanism, as I understand it, is almost never used these days. Regards, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems with reshape2 on Mac
Is this a recent version of R? If so, please report to the maintainer. Otherwise, please also report that it does not work with your version of R so that the maintainer can add a version dependency. Best, Uwe Ligges On 13.09.2010 17:42, Paul Metzner wrote: Hi! I updated to reshape2 yesterday and tried to make it work. Unfortunately, it mainly throws error messages at me (good thing it's reshape2 1.0 and not reshape 2.0). The most recent is: Error in match.fun(FUN) : object 'id' not found When I manually create an object 'id', it says: Error in get(as.character(FUN), mode = function, envir = envir) : object 'id' of mode 'function' was not found I assume that dcast is looking for a function by the name 'id' which is not present. I tried both Rdaemon within TextMate and R in the Terminal. I also tried both my own code and the airquality example. reshape is still working flawlessly. I also needed to load plyr manually to make another error message go away, that asked for 'as.quoted'. Best, Paul --- Paul Metzner Humboldt-Universität zu Berlin Philosophische Fakultät II Institut für deutsche Sprache und Linguistik Post: Unter den Linden 6 | 10099 Berlin | Deutschland Besuch: Dorotheenstraße 24 | 10117 Berlin | Deutschland +49-(0)30-2093-9726 paul.metz...@rz.hu-berlin.de http://amor.rz.hu-berlin.de/~metznerp/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] as.Date() add a day to a date
On Sep 13, 2010, at 11:56 AM, Andrew Yee wrote: I'm trying to understand why as.Date() is converting a the modified date of a file from August 22 to August 23. foo - file.info(file.to.process) str(foo) 'data.frame': 1 obs. of 10 variables: $ size : num 5.37e+09 $ isdir : logi FALSE $ mode :Class 'octmode' int 436 $ mtime : POSIXct, format: 2010-08-22 23:14:52 $ ctime : POSIXct, format: 2010-09-13 11:34:31 $ atime : POSIXct, format: 2010-09-09 15:42:00 $ uid : int 503 $ gid : int 503 $ uname : chr ayee $ grname: chr ayee as.Date(foo$mtime) [1] 2010-08-23 In this case as.Date(foo$mtime) gives August 23. I would have expected August 22. You are pretty close to midnight. Probably a TZ issue. Check your locale settings versus UTC/GMT. dt - as.POSIXct(2010-08-22 23:14:52) as.Date(dt) [1] 2010-08-23 Happens to me too, but when its 23:14 here, (US-EDT) it's the next day in Greenwich. The help page says: The last [POSIXct] is converted to days by ignoring the time after midnight in the representation of the time in UTC. That is not entirely clear to my reading, but I am forced to conclude that it means as.Date returns the Date in UTC terms rather than in local terms. -- David. Thanks, Andrew sessionInfo() R version 2.11.1 Patched (2010-09-11 r52901) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[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 West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Overlay of two graphs of different axes
The zoomplot or updateusr functions in the TeachingDemos package may help. But be cautious, the thing that grabs the most attention is where 2 (or more) lines cross, when you plot multiple lines on different scales the crossing is meaningless, but that meaningless point is what draws the eyes. Your best option may be to do several juxtaposed plots using layout or par(mfrow -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Uwe Dippel Sent: Sunday, September 12, 2010 11:54 PM To: r-help@r-project.org Subject: [R] Overlay of two graphs of different axes Though I have read quite a bit, and tried quite a bit, I have yet to find a nice way to overlay 2 or more curves in the same plot, with different ranges. Here is simplified sample code to demonstrate the question: plot(2*(seq(1,5)), type=l, axes=FALSE) curve(2*(seq(1,5)), type=b, add=TRUE) Error in curve(2 * (seq(1, 5)), type = b, add = TRUE) : 'expr' must be a function or an expression containing 'x' axis(2) curve(x^2, 1, 5, type=b, add=TRUE) axis(4) Firstly, as an aside, I am not clear why 'curve' has a different syntax compared to 'plot'. As a still beginner, I'd for one would be happy to add curves to a plot; curves of just different parameters. Though, I guess, there must be a good reason? Mostly, however, I wonder how to plot a number of curves into an original plot, that re-defines the min/max from the most recent curve. In the example that I constructed, axis(2) does exactly the expected thing. What I want to do next, though, with the least effort, is to add another function in a manner that the added function is scaled, not according to the first function (plot), but to fit into the plotting area. (The example above overshoots the range). Plus, how can I subsequently add the axis suitable to the most recent function? That is, how can I render axis(4) to displaying the scale for the second graph, created with 'curve'? Thanks in advance, Uwe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Saveing plot to multiple locations
?dev.copy -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Joel Sent: Monday, September 13, 2010 7:13 AM To: r-help@r-project.org Subject: Re: [R] Saveing plot to multiple locations Thx for all the help! Dave: Its the second ones so now it looks like this and works but its abit ugly as you have to plot the same thing two times but dossent seem to be any other way or? try(png('/home/joel/Skrivbord/mammamu2.png')) plot(irisct) dev.off() pdf('/home/joel/Skrivbord/mammamu.pdf') plot(irisct) dev.off() -- View this message in context: http://r.789695.n4.nabble.com/Saveing- plot-to-multiple-locations-tp2537133p2537402.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] sum to infinity
On Sep 13, 2010, at 5:24 AM, tuggi wrote: hello, can i calculate a sum to infinity in R. i want to do something like this: \sum_{i=0}^\infty \frac{2^{-d-1}}{\Gamma(\frac{d-1}{2})}\left(\frac{\Gamma(2d-3)(2- d)_{i}\Gamma(i+1,-z/2)2^{i+1}}{\Gamma(d-1)(4-2d)_{i}i!}\right)+ \\ \sum_{i=0}^\infty \frac{2^{-d-1}}{\Gamma(\frac{d-1}{2})}\left(\frac{\Gamma(3-2d) (d-1)_{i}\Gamma(2d-2+i,-z/2)2^{2d-2+i}}{\Gamma(2-d)(2d-2)_{i}}\right), where (a)_{i}=\Gamma(a+i) / \Gamma(a) . I hope someone can help me. Are you aware of the RYacas interface to the symbolic algebra YACAS. (I'm not sure I have all the caps set correctly, but your search engine probably won't care.) -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to do a trig regression
Without the square term you can just use the rule for addition in sines: sin(a+b) = sin(a)cos(b) + cos(a)sin(b) So a regression of y= a + b* sin(2*pi/360*x + c) can be fit as: lm( y~ sin( 2*pi/360*x) + cos( 2*pi/360/x ) ) If you need the actual values of b and c then you will need to do a little algebra. The same idea may be sufficient for your formula (or at least a close approximation), or you could switch to nonlinear fits using the nls function and fit your formula directly. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Aaditya Nanduri Sent: Sunday, September 12, 2010 8:23 PM To: r-help@r-project.org Subject: [R] How to do a trig regression Hello All, I cant seem to do a trig regression in R. The equation is as follows : y = a+b*(sin((2*pi*x/360) - c))^2 a, b, c are coefs that I want. y, x are input vectors. The equation I put into R: lm(y ~ sin(2*pi*x/360)^2) This equation is missing the c and I dont get the right answer. Also, I dont know how to plot the lm over the x values instead of the indices. Any help is sincerely appreciated. Thank you all very much. -- Aaditya Nanduri aaditya.nand...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 a vector repeatedly
On Sep 13, 2010, at 10:30 AM, James Hudson wrote: I‚d like to sample the vector „y‰ repeatedly. In this dummy dataset, I‚d like to sample (and store) it 1, 2, and 3 times. Is there a straightforward way to do this without using a „for‰ loop? x - c(1 :3) y - c(1:10) (run.sample - sample (y, x)) Thanks very much, James Hudson When you say 1, 2 and 3 times, do you mean that you want 1, 2 and 3 elements from 'y' randomly sampled: set.seed(1) sapply(x, function(i) sample(y, i)) [[1]] [1] 3 [[2]] [1] 4 6 [[3]] [1] 10 2 8 Or, do you want the entire 'y' vector permuted 1, 2 and 3 times: set.seed(1) sapply(x, function(i) replicate(i, sample(y))) [[1]] [,1] [1,]3 [2,]4 [3,]5 [4,]7 [5,]2 [6,]8 [7,]9 [8,]6 [9,] 10 [10,]1 [[2]] [,1] [,2] [1,]3 10 [2,]22 [3,]66 [4,] 101 [5,]59 [6,]78 [7,]87 [8,]45 [9,]13 [10,]94 [[3]] [,1] [,2] [,3] [1,]595 [2,]668 [3,]474 [4,]242 [5,] 1081 [6,]8 106 [7,]917 [8,]129 [9,]733 [10,]35 10 I am guessing the first scenario, but included the second just in case. See ?sapply in which help for both sapply() and replicate() is available. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R 2.12.0 scheduled for October 15
This is to announce that we plan to release R version 2.12.0 on Friday, October, 2010. Those directly involved should review the generic schedule at http://developer.r-project.org/release-checklist.html The source tarballs will be made available daily (barring build troubles) via http://cran.r-project.org/src/base-prerelease/ For the R Core Team Peter Dalgaard -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com ___ r-annou...@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-announce __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] as.Date() add a day to a date
Thanks David, now I wonder how you can have as.Date() render the date using local time rather than UTC. Andrew On Mon, Sep 13, 2010 at 12:08 PM, David Winsemius dwinsem...@comcast.netwrote: On Sep 13, 2010, at 11:56 AM, Andrew Yee wrote: I'm trying to understand why as.Date() is converting a the modified date of a file from August 22 to August 23. foo - file.info(file.to.process) str(foo) 'data.frame': 1 obs. of 10 variables: $ size : num 5.37e+09 $ isdir : logi FALSE $ mode :Class 'octmode' int 436 $ mtime : POSIXct, format: 2010-08-22 23:14:52 $ ctime : POSIXct, format: 2010-09-13 11:34:31 $ atime : POSIXct, format: 2010-09-09 15:42:00 $ uid : int 503 $ gid : int 503 $ uname : chr ayee $ grname: chr ayee as.Date(foo$mtime) [1] 2010-08-23 In this case as.Date(foo$mtime) gives August 23. I would have expected August 22. You are pretty close to midnight. Probably a TZ issue. Check your locale settings versus UTC/GMT. dt - as.POSIXct(2010-08-22 23:14:52) as.Date(dt) [1] 2010-08-23 Happens to me too, but when its 23:14 here, (US-EDT) it's the next day in Greenwich. The help page says: The last [POSIXct] is converted to days by ignoring the time after midnight in the representation of the time in UTC. That is not entirely clear to my reading, but I am forced to conclude that it means as.Date returns the Date in UTC terms rather than in local terms. -- David. Thanks, Andrew sessionInfo() R version 2.11.1 Patched (2010-09-11 r52901) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[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 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.
[R] R 2.12.0 scheduled for October 15
This is to announce that we plan to release R version 2.12.0 on Friday, October 15, 2010. Those directly involved should review the generic schedule at http://developer.r-project.org/release-checklist.html The source tarballs will be made available daily (barring build troubles) via http://cran.r-project.org/src/base-prerelease/ For the R Core Team Peter Dalgaard -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com ___ r-annou...@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-announce __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 a vector repeatedly
Thank you Marc - the first scenario. On Mon, Sep 13, 2010 at 2:04 PM, Marc Schwartz marc_schwa...@me.com wrote: On Sep 13, 2010, at 10:30 AM, James Hudson wrote: Iâd like to sample the vector âyâ° repeatedly. In this dummy dataset, Iâd like to sample (and store) it 1, 2, and 3 times. Is there a straightforward way to do this without using a âforâ° loop? x - c(1 :3) y - c(1:10) (run.sample - sample (y, x)) Thanks very much, James Hudson When you say 1, 2 and 3 times, do you mean that you want 1, 2 and 3 elements from 'y' randomly sampled: set.seed(1) sapply(x, function(i) sample(y, i)) [[1]] [1] 3 [[2]] [1] 4 6 [[3]] [1] 10 2 8 Or, do you want the entire 'y' vector permuted 1, 2 and 3 times: set.seed(1) sapply(x, function(i) replicate(i, sample(y))) [[1]] [,1] [1,]3 [2,]4 [3,]5 [4,]7 [5,]2 [6,]8 [7,]9 [8,]6 [9,] 10 [10,]1 [[2]] [,1] [,2] [1,]3 10 [2,]22 [3,]66 [4,] 101 [5,]59 [6,]78 [7,]87 [8,]45 [9,]13 [10,]94 [[3]] [,1] [,2] [,3] [1,]595 [2,]668 [3,]474 [4,]242 [5,] 1081 [6,]8 106 [7,]917 [8,]129 [9,]733 [10,]35 10 I am guessing the first scenario, but included the second just in case. See ?sapply in which help for both sapply() and replicate() is available. 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.
Re: [R] reshape matrix entities to columns
thanks for your help I am trying to work around this in R but i have the feeling that this is going to but the center and age next to each other which is not what i need... it might be me not being able to find my head around this but... i need a table with age as columns and center as rows if deleting row and column names from the main matrix will help i can do that... can i get bit of explanation about how things work ( so i can learn the process) thanks again Natasha From: David Winsemius dwinsem...@comcast.net To: Dennis Murphy djmu...@gmail.com Sent: Sun, 12 September, 2010 21:18:26 Subject: Re: [R] reshape matrix entities to columns On Sep 12, 2010, at 3:34 PM, Dennis Murphy wrote: Hi: Natasha said: I changed it so i hope it will look better now the matrix is like this: AgeNo. Age No. AgeNo. Center1 52 8 7 Center210 720 9 4 10 column name = sequence of age-no. But what I want the data to look like is this Age 1 2 3 4 5 6 7 8 9 10 20 Center1 27 Center2 10 7 9 column name= age of ppl entries = number of ppl with that age in on center * It's a continuation of the reshape problem, but we have to change the NAs in the reshaped data frame to zeros first: df2[is.na(df2)] - 0 xtabs(n ~ center + age, data = df2) age center 5 6 7 8 9 10 11 12 13 14 1 0 10 0 13 0 9 0 7 0 10 2 0 0 12 14 0 0 16 0 0 13 3 6 0 0 0 10 0 12 0 9 0 How's that? You've done all the hard work, but the OP wanted the full range of age values from 1:max and that pretty easy to do with one further step that adds entries fo the missing age levels: df3 - rbind(df2, data.frame(center=1,time=1, age=1:max(df2$age), n=0)) xtabs(n ~ center + age, data = df3) age center 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 0 0 0 0 0 10 0 13 0 9 0 7 0 10 2 0 0 0 0 0 0 12 14 0 0 16 0 0 13 3 0 0 0 0 6 0 0 0 10 0 12 0 9 0 --David. Dennis On Sun, Sep 12, 2010 at 9:46 AM, Dennis Murphy djmu...@gmail.com wrote: Hi: Here's a made up example using the reshape function: Input data: df - structure(list(center = 1:3, age1 = c(6L, 7L, 5L), n1 = c(10L, 12L, 6L), age2 = c(8L, 8L, 8L), n2 = c(13L, 14L, NA), age3 = c(10L, 10L, 9L), n3 = c(9L, NA, 10L), age4 = c(12L, 11L, 11L), n4 = c(7L, 16L, 12L), age5 = c(14L, 14L, 13L), n5 = c(10L, 13L, 9L)), .Names = c(center, age1, n1, age2, n2, age3, n3, age4, n4, age5, n5), class = data.frame, row.names = c(NA, -3L)) df center age1 n1 age2 n2 age3 n3 age4 n4 age5 n5 1 16 108 13 10 9 12 7 14 10 2 27 128 14 10 NA 11 16 14 13 3 35 68 NA9 10 11 12 13 9 # To reshape more than one variable at a time, you need # to put the sets of variables into a list, as follows: df2 - reshape(df, idvar = 'center', varying = list(c(paste('age', 1:5, sep = '')), c(paste('n', 1:5, sep = ''))), v.names = c('age', 'n'), times = 1:5, direction = 'long') df2 center time age n 1.1 11 6 10 2.1 21 7 12 3.1 31 5 6 1.2 12 8 13 2.2 22 8 14 3.2 32 8 NA 1.3 13 10 9 2.3 23 10 NA 3.3 33 9 10 1.4 14 12 7 2.4 24 11 16 3.4 34 11 12 1.5 15 14 10 2.5 25 14 13 3.5 35 13 9 HTH, Dennis On Sun, Sep 12, 2010 at 7:45 AM, Natasha Asar Greeting R helpers J I am not familiar with R but I have to use it to analyze data set that I have (30,000 20,000) I want to change the structure of the dataset and I am wondering how that might be possible in R A main data looks like this: some entities are empty AgeNo. AgeNo. AgeNo. Center15 2 8 7 Center210 7 20 9 4 10 But what I want the data to look like is Age1 2 3 4 5 6 7 8 9 10 20 Center1 2 7 Center2 10 7 9 It should read the entities one by one when j is in age column take its value and consider it as the column number for new matrix then go to next entity (j No. columns) and put that entity under the columns number identified in previous step. In other word it should get the each element in No. columns (one by one) and place them in a new matrix under the column number which are equal to entity of
Re: [R] Sample a vector repeatedly
You can try this also: Vectorize(sample, 'size')(y, 1:3) On Mon, Sep 13, 2010 at 12:30 PM, James Hudson jmghud...@gmail.com wrote: Id like to sample the vector y repeatedly. In this dummy dataset, Id like to sample (and store) it 1, 2, and 3 times. Is there a straightforward way to do this without using a for loop? x - c(1 :3) y - c(1:10) (run.sample - sample (y, x)) Thanks very much, James Hudson [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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] as.Date() add a day to a date
On Sep 13, 2010, at 1:24 PM, Andrew Yee wrote: Thanks David, now I wonder how you can have as.Date() render the date using local time rather than UTC. Since we are both in the EDT TZ at the moment, our times are UTC-4 (hours = 60*60 seconds) dt - as.POSIXct(2010-08-22 23:14:52) as.Date(dt -60*60*4) Now == [1] 2010-08-22 #was [1] 2010-08-23 There are probably more elegant and self-documenting methods, but I'm not fully versed in TZ conumdrums. -- David. Andrew On Mon, Sep 13, 2010 at 12:08 PM, David Winsemius dwinsem...@comcast.net wrote: On Sep 13, 2010, at 11:56 AM, Andrew Yee wrote: I'm trying to understand why as.Date() is converting a the modified date of a file from August 22 to August 23. foo - file.info(file.to.process) str(foo) 'data.frame': 1 obs. of 10 variables: $ size : num 5.37e+09 $ isdir : logi FALSE $ mode :Class 'octmode' int 436 $ mtime : POSIXct, format: 2010-08-22 23:14:52 $ ctime : POSIXct, format: 2010-09-13 11:34:31 $ atime : POSIXct, format: 2010-09-09 15:42:00 $ uid : int 503 $ gid : int 503 $ uname : chr ayee $ grname: chr ayee as.Date(foo$mtime) [1] 2010-08-23 In this case as.Date(foo$mtime) gives August 23. I would have expected August 22. You are pretty close to midnight. Probably a TZ issue. Check your locale settings versus UTC/GMT. dt - as.POSIXct(2010-08-22 23:14:52) as.Date(dt) [1] 2010-08-23 Happens to me too, but when its 23:14 here, (US-EDT) it's the next day in Greenwich. The help page says: The last [POSIXct] is converted to days by ignoring the time after midnight in the representation of the time in UTC. That is not entirely clear to my reading, but I am forced to conclude that it means as.Date returns the Date in UTC terms rather than in local terms. -- David. Thanks, Andrew sessionInfo() R version 2.11.1 Patched (2010-09-11 r52901) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[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 West Hartford, CT David Winsemius, MD 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] as.Date() add a day to a date
Henrique, thanks for your suggestion. For my applications, character would have been sufficient, so your suggestion of using format() works fine too. Perhaps I should submit a feature request for as.Date() to let you specify local time. Thanks, Andrew On Mon, Sep 13, 2010 at 2:06 PM, Henrique Dallazuanna www...@gmail.comwrote: Try this: format(dt, '%Y-%m-%d'), if you want Date class: as.Date(format(dt, '%Y-%m-%d')) On Mon, Sep 13, 2010 at 2:24 PM, Andrew Yee y...@post.harvard.edu wrote: Thanks David, now I wonder how you can have as.Date() render the date using local time rather than UTC. Andrew On Mon, Sep 13, 2010 at 12:08 PM, David Winsemius dwinsem...@comcast.net wrote: On Sep 13, 2010, at 11:56 AM, Andrew Yee wrote: I'm trying to understand why as.Date() is converting a the modified date of a file from August 22 to August 23. foo - file.info(file.to.process) str(foo) 'data.frame': 1 obs. of 10 variables: $ size : num 5.37e+09 $ isdir : logi FALSE $ mode :Class 'octmode' int 436 $ mtime : POSIXct, format: 2010-08-22 23:14:52 $ ctime : POSIXct, format: 2010-09-13 11:34:31 $ atime : POSIXct, format: 2010-09-09 15:42:00 $ uid : int 503 $ gid : int 503 $ uname : chr ayee $ grname: chr ayee as.Date(foo$mtime) [1] 2010-08-23 In this case as.Date(foo$mtime) gives August 23. I would have expected August 22. You are pretty close to midnight. Probably a TZ issue. Check your locale settings versus UTC/GMT. dt - as.POSIXct(2010-08-22 23:14:52) as.Date(dt) [1] 2010-08-23 Happens to me too, but when its 23:14 here, (US-EDT) it's the next day in Greenwich. The help page says: The last [POSIXct] is converted to days by ignoring the time after midnight in the representation of the time in UTC. That is not entirely clear to my reading, but I am forced to conclude that it means as.Date returns the Date in UTC terms rather than in local terms. -- David. Thanks, Andrew sessionInfo() R version 2.11.1 Patched (2010-09-11 r52901) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[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 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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] Transforming character vector
Hi guys, Cant seem to find a solution for this. I am looking for a substitute for cut that can transform character vectors. So as cut would be used below to transform YearCat- YearCat2 base on Year and vector Ag-c(00-'70,'71-'75,'76-'85,'86-'09) using 'cut ' FleetData$YearCat-cut(FleetData$Year,c(0,1970,1975,1985,2009),labels=Ag) Make Year YearCat YearCat2 1 DODG2003'86-'09 (2002,2003] 3 FORD1995'86-'09 (1994,1995] 5 JEP 1997'86-'09 (1996,1997] 6 JEP 1997'86-'09 (1996,1997] 7 DODG2002'86-'09 (2001,2002] 8 BMW 1997'86-'09 (1996,1997] 11 TOYT2006'86-'09 (2005,2006] 12 CHEV1997'86-'09 (1996,1997] 13 CHEV1992'86-'09 (1991,1992] 14 CHEV1996'86-'09 (1995,1996] I need to do the same for a fueltype where each record has a character representing the data instead of a numeral(as in year). No reproducible code or data because i think this is pretty straight forward. I could do this using a series of loops but i think there is prob a more elegant way. Use of grep? Thanks for the help JR -- View this message in context: http://r.789695.n4.nabble.com/Transforming-character-vector-tp2537881p2537881.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.Date() add a day to a date
Try this: format(dt, '%Y-%m-%d'), if you want Date class: as.Date(format(dt, '%Y-%m-%d')) On Mon, Sep 13, 2010 at 2:24 PM, Andrew Yee y...@post.harvard.edu wrote: Thanks David, now I wonder how you can have as.Date() render the date using local time rather than UTC. Andrew On Mon, Sep 13, 2010 at 12:08 PM, David Winsemius dwinsem...@comcast.net wrote: On Sep 13, 2010, at 11:56 AM, Andrew Yee wrote: I'm trying to understand why as.Date() is converting a the modified date of a file from August 22 to August 23. foo - file.info(file.to.process) str(foo) 'data.frame': 1 obs. of 10 variables: $ size : num 5.37e+09 $ isdir : logi FALSE $ mode :Class 'octmode' int 436 $ mtime : POSIXct, format: 2010-08-22 23:14:52 $ ctime : POSIXct, format: 2010-09-13 11:34:31 $ atime : POSIXct, format: 2010-09-09 15:42:00 $ uid : int 503 $ gid : int 503 $ uname : chr ayee $ grname: chr ayee as.Date(foo$mtime) [1] 2010-08-23 In this case as.Date(foo$mtime) gives August 23. I would have expected August 22. You are pretty close to midnight. Probably a TZ issue. Check your locale settings versus UTC/GMT. dt - as.POSIXct(2010-08-22 23:14:52) as.Date(dt) [1] 2010-08-23 Happens to me too, but when its 23:14 here, (US-EDT) it's the next day in Greenwich. The help page says: The last [POSIXct] is converted to days by ignoring the time after midnight in the representation of the time in UTC. That is not entirely clear to my reading, but I am forced to conclude that it means as.Date returns the Date in UTC terms rather than in local terms. -- David. Thanks, Andrew sessionInfo() R version 2.11.1 Patched (2010-09-11 r52901) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[alternative HTML version deleted]] -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] using survexp and ratetable with coxph object that includes a factor term
Hello, I'm attempting to use the ratetable argument to survexp in the survival package. I use the example from the ?survexp help page below, and then slightly modify it to produce an error. library(survival) data(pbc) #fit a model without any factors pfit1 - coxph(Surv(time, status 0) ~ trt + log(bili) + log(protime) + age + platelet, data=pbc) #this works as expected survexp(~ trt, ratetable = pfit1, data = pbc) #now I fit a similar model, simply adding the 'sex' term #note sex is now the only factor in the model pfit2 - coxph(Surv(time, status 0) ~ trt + log(bili) + log(protime) + age + platelet + sex, data = pbc) #however, I now get an error with survexp survexp(~ trt, ratetable = pfit2, data = pbc) Error in ratetable(trt = trt, bili = bili, protime = protime, age = age, : object 'sexf' not found Does anyone have any suggestions? Thank you, Erik Iverson sessionInfo() R version 2.11.1 (2010-05-31) x86_64-unknown-linux-gnu locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] grDevices datasets splines graphics utils stats methods [8] base other attached packages: [1] Hmisc_3.7-0 survival_2.35-8 loaded via a namespace (and not attached): [1] cluster_1.12.3 grid_2.11.1lattice_0.18-8 tools_2.11.1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] New version of rms package on CRAN
CRAN has a significant update to rms. Windows and unix/linux versions are available and I expect the Mac version to be available soon. The most significant improvement is addition of latex=TRUE arguments to model fitting print methods, made especially for use with Sweave. Here is a summary of changes since the previous version. Changes in version 3.1-0 (2010-09-12) * Fixed gIndex to not use scale for labeling unless character * Changed default na.action in Gls to na.omit and added a note in the help file that na.delete does not work with Gls * Added terms component to Gls fit object (latex was not working) * Added examples in robcov help file testing sandwich covariance estimator * Added reference related to the effects package under help file for plot.Predict * Added more examples and simulations to gIndex * Fixed ancient bug in lrm.fit Fortran code to handle case where initial estimates are nearly perfect (was trying to step halve); thanks: Dan Hogan * Changed survdiffplot to use gray(.85) for bands instead of gray(.95) * Fixed formatting problem in print.psm * Added prStats and reVector functions to rmsMisc.s * Changed formatting of all print.* functions for model fits to use new prStats function * Added latex=TRUE option to all model fit print methods; requires LaTeX package needspace * Re-wrote printing routines to make use of more general model * Removed long and scale options from cph printing-related routines * Prepare for version 2.36-1 of survival package by adding censor=FALSE argument to survfit.coxph * Added type=ccterms to various predict methods * Made type=ccterms the default for partial g-indexes in gIndex, i.e., combine all indirectly related (through interactions) terms * Added Spiegelhalter calibration test to val.prob * Added a check in cph to trigger an error if strata() is used in formula * Fixed drawing of polygon for shaded confidence bands for survplot.survfit (thanks to Patrick Breheny patrick.breh...@uky.edu) * Changed default adjust.subtitle in bplot to depend on ref.zero, thanks to David Winsemius dwinsem...@comcast.net * Used a namespace and simplified referenced to a few survival package functions that survival actually exports Frank E Harrell Jr Professor and ChairmanSchool of Medicine Department of Biostatistics Vanderbilt University ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] list with explanation for trellis parameters available?
Dears, does anyone know whether there is any complete list with explanations for the several Trellis parameters (i.e. the ones you one gets with trellis.par.set() ) available? Many of them are self explanatory or easy to guess but there is such a vast amount of them that this is not possible for all of them. I looked through the various help pages but the only helpful information was : ...The actual list of the components in trellis.settings has not been finalized, so I'm not attempting to list them here... Is there any hope to find such an explanation? I have messed around with several of them but many interact in a not too straightforward way, so a clear definition would certainly help. I know Deepayan Sarkar wrote a book about Trellis, but I have not bought it (yet). Cheers Jannis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Transforming character vector
LCOG1 jroll at lcog.org writes: [snip] I need to do the same for a fueltype where each record has a character representing the data instead of a numeral(as in year). No reproducible code or data because i think this is pretty straight forward. I could do this using a series of loops but i think there is prob a more elegant way. Use of grep? Thanks for the help Reproducible would still help because we still have to do a bit of guessing about what you mean. How do you want to define the ordering on characters? If the number of fuel types is small enough, you could just create a factor and cut() on the numeric values , e.g. fueltype - factor(c(A,A,B,E,Q),levels=LETTERS) cut(as.numeric(fueltype),c(-0.5,13.5,26.5),labels=c(A-M,N-Z)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Problems with reshape2 on Mac
Hi Uwe, The problem is most likely because the original poster doesn't have the latest version of plyr. I correctly declare this dependency in the DESCRIPTION (http://cran.r-project.org/web/packages/reshape2/index.html), but unfortunately R doesn't seem to use this information at run time, generally creating many error reports of this nature. Hadley 2010/9/13 Uwe Ligges lig...@statistik.tu-dortmund.de: Is this a recent version of R? If so, please report to the maintainer. Otherwise, please also report that it does not work with your version of R so that the maintainer can add a version dependency. Best, Uwe Ligges On 13.09.2010 17:42, Paul Metzner wrote: Hi! I updated to reshape2 yesterday and tried to make it work. Unfortunately, it mainly throws error messages at me (good thing it's reshape2 1.0 and not reshape 2.0). The most recent is: Error in match.fun(FUN) : object 'id' not found When I manually create an object 'id', it says: Error in get(as.character(FUN), mode = function, envir = envir) : object 'id' of mode 'function' was not found I assume that dcast is looking for a function by the name 'id' which is not present. I tried both Rdaemon within TextMate and R in the Terminal. I also tried both my own code and the airquality example. reshape is still working flawlessly. I also needed to load plyr manually to make another error message go away, that asked for 'as.quoted'. Best, Paul --- Paul Metzner Humboldt-Universität zu Berlin Philosophische Fakultät II Institut für deutsche Sprache und Linguistik Post: Unter den Linden 6 | 10099 Berlin | Deutschland Besuch: Dorotheenstraße 24 | 10117 Berlin | Deutschland +49-(0)30-2093-9726 paul.metz...@rz.hu-berlin.de http://amor.rz.hu-berlin.de/~metznerp/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] The future of R - Ross Ihaka stirs discussions around the web
Hello all, There is currently a (very !) lively discussions happening around the web, surrounding the following topics: 1) Is R efficient? (scripting wise, and performance wise) 2) Should R be written from scratch? 3) What should be the license of R (if it was made a new)? Very serious people have taken part in the debates so far. I hope to let you know of the places I came by, so you might be able to follow/participate in these (IMHO) important discussions. The discussions started in the response for the following blog post on Xi'An's blog: http://xianblog.wordpress.com/2010/09/06/insane/ Followed by the (short) response post by Ross Ihaka: http://xianblog.wordpress.com/2010/09/13/simply-start-over-and-build-something-better/ Other discussions started to appear on Andrew Gelman's blog: http://www.stat.columbia.edu/~cook/movabletype/archives/2010/09/ross_ihaka_to_r.html And (many) more responses started to appear in the hackers news website: http://news.ycombinator.com/item?id=1687054 I hope these discussions will have fruitful results for our community, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[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 tell R that ABC is the name of a dataset not a variable value
All, For example, I have a dataset named ABC loaded into R ABC [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 and I also have a variable datasetname datasetname [1] ABC and I want to add this ABC dataset to an existing list alldata alldata -NULL alldata - as.list(alldata) since I will have lots of datasets like ABC loaded to R, and have datasetname variable record their names, I want to add all the datasets to the list alldata by just writing one command. But I don't know to tell R that ABC is a dataset's name instead of a value of variable datasetname? Thank you all for your help! JL [[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] Question: Form a new list with the index replicated equal to the number of elements in that index
Dear R-Helpers, I have a list l1 like: l1[[1]] a b c l1[[2]] d l1[[3]] e f I want an output res like: res[[1]] 1 1 1 res[[2]] 2 res[[3]] 3 3 Essentially, I want to replicate each index equal to the number of elements present in that index. Below is what I do to accomplish this: l1 - list(c(a, b, c), d, c(e, f)) res - mapply(rep, seq_along(l1),times=(lapply(l1, length))) Is there a more elegant way of doing this (possibly using one (l/m)apply function)? Thanks in advance for the help. Best Regards, S. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to tell R that ABC is the name of a dataset not a variable value
Se ?get function. On Mon, Sep 13, 2010 at 3:40 PM, Jie Li ruser...@gmail.com wrote: All, For example, I have a dataset named ABC loaded into R ABC [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 and I also have a variable datasetname datasetname [1] ABC and I want to add this ABC dataset to an existing list alldata alldata -NULL alldata - as.list(alldata) since I will have lots of datasets like ABC loaded to R, and have datasetname variable record their names, I want to add all the datasets to the list alldata by just writing one command. But I don't know to tell R that ABC is a dataset's name instead of a value of variable datasetname? Thank you all for your help! JL [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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] Transparent Labels for Polar Plot
Hello, I am currently using the polar.plot function in the plotrix package to graph data. Unfortunately, it seems that the default for the labels is to have a background color that is covering the line representing my data, making it difficult to read. Is there a way to make this label background transparent? Example: lengths - 0:72 bearing - seq(from=0, to=360, by=5) polar.plot(lengths, bearing, labels = seq(from=0, to=340, by=20),label.pos = seq(from=0, to=340, by=20), start=90, clockwise=TRUE, rp.type=p, line.col=aquamarine3, lwd=2, main=Title, radial.lim=seq(from=0, to=90, by=15)) ##label at length 20 blocks view of the line around bearing 100 Thanks for your help! -Jimmy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 tell R that ABC is the name of a dataset not a variable value
Hi, Just to provide an example: #Sample data copied to variables X, Y, and Z Z - Y - X - data.frame(A = 1:10) # A variable holding the names of the variables datasetname - c(X, Y, Z) # Use mget() to collect all the variables in a list # get() only gets one variable at a t ime, mget() gets multiple # however, mget() needs to know which environment to look in # If your variables are just in your usual workspace # it should be .GlobalEnv alldata - mget(x = datasetname, envir = .GlobalEnv) HTH, Josh On Mon, Sep 13, 2010 at 11:40 AM, Jie Li ruser...@gmail.com wrote: All, For example, I have a dataset named ABC loaded into R ABC [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 and I also have a variable datasetname datasetname [1] ABC and I want to add this ABC dataset to an existing list alldata alldata -NULL alldata - as.list(alldata) since I will have lots of datasets like ABC loaded to R, and have datasetname variable record their names, I want to add all the datasets to the list alldata by just writing one command. But I don't know to tell R that ABC is a dataset's name instead of a value of variable datasetname? Thank you all for your help! JL [[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/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] lattice: Set x-axis in italics only
Thanks all for the excellent help! Kind regards, Alej 2010/9/13 Dennis Murphy djmu...@gmail.com: Hi: demo(graphics) has a lot of nice examples of how to use various features - one of them is font selection. font = 3 = italic font = 4 = bold italic You need to select the correct aspect of the plot, however: font.main, font.sub, font.lab or font.axis (from par()). HTH, Dennis On Mon, Sep 13, 2010 at 5:50 AM, Alejo C.S. alej@gmail.com wrote: Dear list, I making some box-and-whisker plots in R with vertebrate data. The x axis are species names that must be in italics. I tried with the axis function but no luck, and it seems that affects both axes. Any tip? Thanks a lot in Advance. Alej __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Dampening the spline interpolation for contours
Hello all, I'm very new to R and am having some trouble with the results of the interp function. I'm trying to produce a chart roughly akin to a weather map with natural looking filled contours over a large region of the south pacific. I've got a list of points and values to be mapped to those points and I use the interp function as follows: tab-read.table(data.txt) library(akima) png(contour.png, width = 1000, height=500) colourRange-colorRampPalette(c(#f9cd00,#f9cd00,#f9cd00,#f9cd00,#ff,#6afaff,#53a3ff,#53a3ff,#53a3ff)) filled.contour(interp(x=tab$V1,tab$V2, tab$V3, xo=seq(min(tab$V1), max(tab$V1),length=1000),yo=seq(min(tab$V2), max(tab$V2),length=500), linear = FALSE), xlim = range(160,190),ylim = range(-30,-10), zlim=c(-4,4),color.palette = colourRange ) dev.off() rm(list = ls()) I have added the rm(list=ls()) on the end to try to reset the workspace because I've found that repeated running of this code can result in different output images. The main problem I am having is that though my values are all between -2.5 and 2.5 the interpolation gives me values well outside that range. Usually shown by colouring the areas white but confirmed by plotting a regular contour map instead of a filled contour. What I'd like to find out is if there is a way to dampen the cubic spline that is being used, or if there is an alternative to interp() that I should be looking at. Like I said before, I'm very new to R, so I may have missed something entirely obvious. Thanks in advance, Craig __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Question: Form a new list with the index replicated equal to the number of elements in that index
Sunny - I don't think mapply is needed: lapply(1:length(mylist),function(x)rep(x,length(mylist[[x]]))) [[1]] [1] 1 1 1 [[2]] [1] 2 [[3]] [1] 3 3 - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Mon, 13 Sep 2010, Sunny Srivastava wrote: Dear R-Helpers, I have a list l1 like: l1[[1]] a b c l1[[2]] d l1[[3]] e f I want an output res like: res[[1]] 1 1 1 res[[2]] 2 res[[3]] 3 3 Essentially, I want to replicate each index equal to the number of elements present in that index. Below is what I do to accomplish this: l1 - list(c(a, b, c), d, c(e, f)) res - mapply(rep, seq_along(l1),times=(lapply(l1, length))) Is there a more elegant way of doing this (possibly using one (l/m)apply function)? Thanks in advance for the help. Best Regards, S. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Dampening the spline interpolation for contours
Although not an R solution, I would highly recommend the generic mapping tools GMT for this type of work. http://gmt.soest.hawaii.edu/ Cheers, Dylan On Monday 13 September 2010, Craig Stanton wrote: Hello all, I'm very new to R and am having some trouble with the results of the interp function. I'm trying to produce a chart roughly akin to a weather map with natural looking filled contours over a large region of the south pacific. I've got a list of points and values to be mapped to those points and I use the interp function as follows: tab-read.table(data.txt) library(akima) png(contour.png, width = 1000, height=500) colourRange-colorRampPalette(c(#f9cd00,#f9cd00,#f9cd00,#f9cd00,#f f,#6afaff,#53a3ff,#53a3ff,#53a3ff)) filled.contour(interp(x=tab$V1,tab$V2, tab$V3, xo=seq(min(tab$V1), max(tab$V1),length=1000),yo=seq(min(tab$V2), max(tab$V2),length=500), linear = FALSE), xlim = range(160,190),ylim = range(-30,-10), zlim=c(-4,4),color.palette = colourRange ) dev.off() rm(list = ls()) I have added the rm(list=ls()) on the end to try to reset the workspace because I've found that repeated running of this code can result in different output images. The main problem I am having is that though my values are all between -2.5 and 2.5 the interpolation gives me values well outside that range. Usually shown by colouring the areas white but confirmed by plotting a regular contour map instead of a filled contour. What I'd like to find out is if there is a way to dampen the cubic spline that is being used, or if there is an alternative to interp() that I should be looking at. Like I said before, I'm very new to R, so I may have missed something entirely obvious. Thanks in advance, Craig __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dylan Beaudette Soil Resource Laboratory http://casoilresource.lawr.ucdavis.edu/ University of California at Davis 530.754.7341 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] The future of R - Ross Ihaka stirs discussions around the web
There was an award session at the Vancouver JSM where both Ross Ihaka and Robert Gentleman spoke. The simply-start-over post sounds very much like Ross's JSM talk. Robert's response was much more positive - coming from the perspective of developing BioConductor I think. I don't recall the details, but the cartoon version is something like R isn't really broken. albyn On Mon, Sep 13, 2010 at 09:51:39PM +0200, Tal Galili wrote: Hello all, There is currently a (very !) lively discussions happening around the web, surrounding the following topics: 1) Is R efficient? (scripting wise, and performance wise) 2) Should R be written from scratch? 3) What should be the license of R (if it was made a new)? Very serious people have taken part in the debates so far. I hope to let you know of the places I came by, so you might be able to follow/participate in these (IMHO) important discussions. The discussions started in the response for the following blog post on Xi'An's blog: http://xianblog.wordpress.com/2010/09/06/insane/ Followed by the (short) response post by Ross Ihaka: http://xianblog.wordpress.com/2010/09/13/simply-start-over-and-build-something-better/ Other discussions started to appear on Andrew Gelman's blog: http://www.stat.columbia.edu/~cook/movabletype/archives/2010/09/ross_ihaka_to_r.html And (many) more responses started to appear in the hackers news website: http://news.ycombinator.com/item?id=1687054 I hope these discussions will have fruitful results for our community, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[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. -- Albyn Jones Reed College jo...@reed.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] apply over parallel lists and their elements
Hello On Sun, Sep 12, 2010 at 5:37 PM, Sebastian Gibb li...@sebastiangibb.de wrote: Hello, thanks for your answer. mapply fits to my needs. One thing that seems strange is that if you use tree[[1]]$node$values - 1:10 tree[[2]]$node$values - 3:12 you still get mapply(mean, tree[[1]]$node$values, tree[[2]]$node$values) [1] 1 2 3 4 5 6 7 8 9 10 But I cannot understand what's wrong. But I don't know how many items would tree have. I can't write them all by hand. How can I generate the arguments for mapply? Unfortunately I cannot think of a solution. Perhaps reorganise your data, so that all relevant data points go into the same vector. For example, tree[[4]]-list(); tree[[4]][['node']]-list(); tree[[4]]$node$more[[1]] - 1:10 tree[[4]]$node$more[[2]] - 3:12 mapply(mean, tree[[4]]$node$more) [1] 5.5 7.5 Also check maply and mlply to see if they can fit your needs. [1] Regards Liviu [1] http://had.co.nz/plyr/plyr-intro-090510.pdf mapply(mean, tree[[1]]$node$values, tree[[2]]$node$values, ... tree[[k]]$node$values); Kind regards, Sebastian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.