Re: [R] Weird SEs with effect()
Hi John, In fact I am still a little bit confused because I had read the ?effect help and the archives. ?effect says that the confidence intervals are on the linear predictor scale as well. Using exp() on the untransformed confidence intervals gives me the same values as summary(eff). My confidence intervals seems to be correct and reflects the results from my glm models. But when I use exp() to get the correct SEs on the response scale I get SEs that sometimes do not make sense at all. Interestingly I have found a trend. For my model with adjusted means ~ 0.5-1.5 I get huge SEs (SEs 1, but my glm model shows significant differences between level 1 = 0.55 and level 2 = 1.15). Models with means around 10-20 my SEs are fine with exp(). Models with means around 75-125 my SEs get way too small with exp(). Something is not right here (or maybe they are but I don not understand it) so I think my best option will be to use the confidence intervals instead of SEs in my plot. Regards, Gustaf Quoting John Fox [EMAIL PROTECTED]: Dear Gustaf, From ?effect, se: a vector of standard errors for the effect, on the scale of the linear predictor. Does that help? Regards, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Gustaf Granath Sent: February-16-08 11:43 AM To: r-help@r-project.org Subject: [R] Weird SEs with effect() Hi all, Im a little bit confused concerning the effect() command, effects package. I have done several glm models with family=quasipoisson: model -glm(Y~X+Q+Z,family=quasipoisson) and then used results.effects -effect(X,model,se=TRUE) to get the adjusted means. I am aware about the debate concerning adjusted means, but you guys just have to trust me - it makes sense for me. Now I want standard error for these means. results.effects$se gives me standard error, but it is now it starts to get confusing. The given standard errors are very very very small - not realistic. I thought that maybe these standard errors are not back transformed so I used exp() and then the standard errors became realistic. However, for one of my glm models with quasipoisson the standard errors make kind of sense without using exp() and gets way to big if I use exp(). To be honest, I get the feeling that Im on the wrong track here. Basically, I want to know how SE is calculated in effect() (all I know is that the reported standard errors are for the fitted values) and if anyone knows what is going on here. Regards, Gustaf Granath __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Transfer Crosstable to Word-Document
Gabor Grothendieck wrote: On Feb 16, 2008 5:28 PM, David Scott [EMAIL PROTECTED] wrote: On Sat, 16 Feb 2008, Alan Zaslavsky wrote: If you want to get nicely formatted tables in Word and are familiar with Office tools (I know it's the Evil Empire but some of us work there), I suggest that you use Excel for formatting and then insert the table into your Word document. IMHO, Excel is much superior to Word for table formatting, e.g. modifying number of significant digits, playing around with fonts and number formats, etc. And when you have gotten the formats right you can paste in modified values of the numbers in the table without having to do the formatting again. Including the table in your Word document is easy by cut-paste or creating a live link. As a user of R under Unix I haven't looked into the facilities for writing tables to Excel under Windows but there is something there. Alternatively you can write a fixed-column or tab-delimited file and easily import to Excel. Production of tables and formatting them in Word is something I have dealt with a couple of times recently and it really is important to do something smart because of the time taken to individually format tables. An approach I used recently was to produce a text table in R and export it to Excel as a .csv file which could then be copied as is to Word. Borders and the like would still have to be formatted individually but not entries You could get a border automatically by writing your table out as HTML. Try this using the builtin data frame iris: library(R2HTML) HTML(iris, border = 1, file(clipboard,w), append=FALSE) Now paste that into Excel and from Excel into Word and you should have a border around it. See ?HTML.data.frame You could alternately generate the HTML yourself giving quite a bit of control. Just curious (I don't use Word if I can help it -- even the simplest of things drive me up the wall), but can you not import HTML directly in Word? OpenOffice seems to do it quite happily with xtable output. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Package Implementing Kohavi's Wrapper Method for Subset
Hi List, I am looking for a R package that implements Kohavi John's wrapper methods for feature subset selection. Do you know whether there is a such kind of R package? Ref: R. Kohavi and G. H. John, Wrappers for feature subset selection, Artificial Intelligence, vol. 97, no. 1-2, pp. 273324, 1997. Thanks a lot, Vu Computer Science Department University of Southern California [[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 specify the location of tick mark on x axies
Xin wrote: Dear: I want to plot barplot and let bar be in the middle of each x axis category. Do you have this experience? Hi Xin, The barp function in the plotrix package centers the bars on integer values. This might make it a bit easier to do what you want. 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] Weird SEs with effect()
On Sun, 17 Feb 2008, Gustaf Granath wrote: Hi John, In fact I am still a little bit confused because I had read the ?effect help and the archives. ?effect says that the confidence intervals are on the linear predictor scale as well. Using exp() on the untransformed confidence intervals gives me the same values as summary(eff). My confidence intervals seems to be correct and reflects the results from my glm models. But when I use exp() to get the correct SEs on the response scale I get SEs that sometimes do not make sense at all. Interestingly I have What exactly are you doing here? I suspect you are not using the correct formula to transform the SEs (you do not just exponeniate them), but without the reproducible example asked for we cannot tell. found a trend. For my model with adjusted means ~ 0.5-1.5 I get huge SEs (SEs 1, but my glm model shows significant differences between level 1 = 0.55 and level 2 = 1.15). Models with means around 10-20 my SEs are fine with exp(). Models with means around 75-125 my SEs get way too small with exp(). Something is not right here (or maybe they are but I don not understand it) so I think my best option will be to use the confidence intervals instead of SEs in my plot. If you want confidence intervals, you are better off computing those on a reasonable scale and transforming then. Or using a profile likelihood to compute them (which will be equivariant under monotone scale transformations). Regards, Gustaf Quoting John Fox [EMAIL PROTECTED]: Dear Gustaf, From ?effect, se: a vector of standard errors for the effect, on the scale of the linear predictor. Does that help? Regards, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Gustaf Granath Sent: February-16-08 11:43 AM To: r-help@r-project.org Subject: [R] Weird SEs with effect() Hi all, Im a little bit confused concerning the effect() command, effects package. I have done several glm models with family=quasipoisson: model -glm(Y~X+Q+Z,family=quasipoisson) and then used results.effects -effect(X,model,se=TRUE) to get the adjusted means. I am aware about the debate concerning adjusted means, but you guys just have to trust me - it makes sense for me. Now I want standard error for these means. results.effects$se gives me standard error, but it is now it starts to get confusing. The given standard errors are very very very small - not realistic. I thought that maybe these standard errors are not back transformed so I used exp() and then the standard errors became realistic. However, for one of my glm models with quasipoisson the standard errors make kind of sense without using exp() and gets way to big if I use exp(). To be honest, I get the feeling that Im on the wrong track here. Basically, I want to know how SE is calculated in effect() (all I know is that the reported standard errors are for the fitted values) and if anyone knows what is going on here. Regards, Gustaf Granath __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error massage in attaching package 'rgl'
Hi, I am getting following error message while attaching 'rgl' package : library(rgl) Error in get(Info[i, 1], envir = env) : internal error in R_decompress1 Can anyone tell me what should I do here? Regards, - 5, 50, 500, 5000 - Store N number of mails in your inbox. Click here. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error massage in attaching package 'rgl'
I am using 2.6.0 version in usual Windows-XP platform Duncan Murdoch [EMAIL PROTECTED] wrote: On 17/02/2008 8:15 AM, stat stat wrote: Hi, I am getting following error message while attaching 'rgl' package : library(rgl) Error in get(Info[i, 1], envir = env) : internal error in R_decompress1 Can anyone tell me what should I do here? Not unless you give a proper error report. Versions? Platform? Duncan Murdoch thanks in advance - 5, 50, 500, 5000 - Store N number of mails in your inbox. Click here. [[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] Transfer Crosstable to Word-Document
On Feb 17, 2008 2:49 PM, Udo König [EMAIL PROTECTED] wrote: [...] Greg: To the odfWeave package: in [2] I found the sentence The package is currently limited to creating text documents using OpenOffice. So it doesn´t seem work with MS-Word? Udo, I think odfWeave is exactly what you need here. You can also use it with MS-Word via the SUN ODF Plugin for MS Office. It adds the capability to load and save odf docs within MS Office. Get the (free as in beer) plugin from here: http://www.sun.com/software/star/odf_plugin/whats_new.jsp Then write your document in Word, save as ODF, run odfWeave, load the result in Word and save as .doc. HTH, Tobias __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] filled.contour with log axis
On 16/02/2008 7:33 PM, Thomas Hoffmann wrote: Dear all, I would like to generate a filled.contour plot with log x and y axis, however using: filled.contour(as.line,log=xy) results in a warning message. Does anybody knos what to do? You could transform your x and y values to their logs, and then use custom axis() calls to plot the axes. For example, a modification of the first example from ?filled.contour: x - 10*1:nrow(volcano) xtick - pretty(x) x - log(x) y - 10*1:ncol(volcano) ytick - pretty(y) y - log(y) filled.contour(x, y, volcano, color = terrain.colors, plot.title = title(main = The Topography of Maunga Whau, xlab = Meters North, ylab = Meters West), plot.axes = { axis(1, at=log(xtick), label=xtick); axis(2, at=log(ytick), label=ytick) }, key.title = title(main=Height\n(meters)), key.axes = axis(4, seq(90, 190, by = 10)))# maybe also asp=1 Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Transfer Crosstable to Word-Document
On Feb 17, 2008 8:20 AM, Gabor Grothendieck [EMAIL PROTECTED] wrote: On Feb 17, 2008 4:41 AM, Peter Dalgaard [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: On Feb 16, 2008 5:28 PM, David Scott [EMAIL PROTECTED] wrote: On Sat, 16 Feb 2008, Alan Zaslavsky wrote: If you want to get nicely formatted tables in Word and are familiar with Office tools (I know it's the Evil Empire but some of us work there), I suggest that you use Excel for formatting and then insert the table into your Word document. IMHO, Excel is much superior to Word for table formatting, e.g. modifying number of significant digits, playing around with fonts and number formats, etc. And when you have gotten the formats right you can paste in modified values of the numbers in the table without having to do the formatting again. Including the table in your Word document is easy by cut-paste or creating a live link. As a user of R under Unix I haven't looked into the facilities for writing tables to Excel under Windows but there is something there. Alternatively you can write a fixed-column or tab-delimited file and easily import to Excel. Production of tables and formatting them in Word is something I have dealt with a couple of times recently and it really is important to do something smart because of the time taken to individually format tables. An approach I used recently was to produce a text table in R and export it to Excel as a .csv file which could then be copied as is to Word. Borders and the like would still have to be formatted individually but not entries You could get a border automatically by writing your table out as HTML. Try this using the builtin data frame iris: library(R2HTML) HTML(iris, border = 1, file(clipboard,w), append=FALSE) Now paste that into Excel and from Excel into Word and you should have a border around it. See ?HTML.data.frame You could alternately generate the HTML yourself giving quite a bit of control. Just curious (I don't use Word if I can help it -- even the simplest of things drive me up the wall), but can you not import HTML directly in Word? OpenOffice seems to do it quite happily with xtable output. You can open an HTML file in Word as a new document and it will be properly formatted and then you could save that document as a Word document and insert it into your main Word document. Alternately, you could copy and paste it from the newly created Word document into your main Word document and that would preserve formatting. Actually you could alternately read the HTML file into Word with formatting preserved using Insert Object Create From File (that's in Word 2007; I think the menus are slightly different in earlier versions) and not use the clipboard at all. That's a bit of a nuisance due to the requirement of creating the intermediate file and having to browse to it in Word. Thus pasting it into Excel and then Word is probably still the fastest but this would be a viable alternative and would be superior if you wanted to generate many tables in R at once and then later add them to Word. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error massage in attaching package 'rgl'
On 17/02/2008 8:15 AM, stat stat wrote: Hi, I am getting following error message while attaching 'rgl' package : library(rgl) Error in get(Info[i, 1], envir = env) : internal error in R_decompress1 Can anyone tell me what should I do here? Not unless you give a proper error report. Versions? Platform? Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Weird SEs with effect()
Dear Brian and Gustaf, I too have a bit of trouble following what Gustaf is doing, but I think that Brian's interpretation -- that Gustaf is trying to transform the standard errors via the inverse link rather than transforming the ends of the confidence intervals -- is probably correct. If this is the case, then what Gustaf has done doesn't make sense. It is possible to get standard errors on the scale of the response (using, e.g., the delta method), but it's probably better to work on the scale of the linear predictor anyway. This is what the summary, print, and plot methods in the effects package do (as is documented in the help files for the package -- see the transformation argument under ?effect and the type argument under ?summary.eff). Regards, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: February-17-08 6:42 AM To: Gustaf Granath Cc: John Fox; r-help@r-project.org Subject: Re: [R] Weird SEs with effect() On Sun, 17 Feb 2008, Gustaf Granath wrote: Hi John, In fact I am still a little bit confused because I had read the ?effect help and the archives. ?effect says that the confidence intervals are on the linear predictor scale as well. Using exp() on the untransformed confidence intervals gives me the same values as summary(eff). My confidence intervals seems to be correct and reflects the results from my glm models. But when I use exp() to get the correct SEs on the response scale I get SEs that sometimes do not make sense at all. Interestingly I have What exactly are you doing here? I suspect you are not using the correct formula to transform the SEs (you do not just exponeniate them), but without the reproducible example asked for we cannot tell. found a trend. For my model with adjusted means ~ 0.5-1.5 I get huge SEs (SEs 1, but my glm model shows significant differences between level 1 = 0.55 and level 2 = 1.15). Models with means around 10-20 my SEs are fine with exp(). Models with means around 75-125 my SEs get way too small with exp(). Something is not right here (or maybe they are but I don not understand it) so I think my best option will be to use the confidence intervals instead of SEs in my plot. If you want confidence intervals, you are better off computing those on a reasonable scale and transforming then. Or using a profile likelihood to compute them (which will be equivariant under monotone scale transformations). Regards, Gustaf Quoting John Fox [EMAIL PROTECTED]: Dear Gustaf, From ?effect, se: a vector of standard errors for the effect, on the scale of the linear predictor. Does that help? Regards, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Gustaf Granath Sent: February-16-08 11:43 AM To: r-help@r-project.org Subject: [R] Weird SEs with effect() Hi all, Im a little bit confused concerning the effect() command, effects package. I have done several glm models with family=quasipoisson: model -glm(Y~X+Q+Z,family=quasipoisson) and then used results.effects -effect(X,model,se=TRUE) to get the adjusted means. I am aware about the debate concerning adjusted means, but you guys just have to trust me - it makes sense for me. Now I want standard error for these means. results.effects$se gives me standard error, but it is now it starts to get confusing. The given standard errors are very very very small - not realistic. I thought that maybe these standard errors are not back transformed so I used exp() and then the standard errors became realistic. However, for one of my glm models with quasipoisson the standard errors make kind of sense without using exp() and gets way to big if I use exp(). To be honest, I get the feeling that Im on the wrong track here. Basically, I want to know how SE is calculated in effect() (all I know is that the reported standard errors are for the fitted values) and if anyone knows what is going on here. Regards, Gustaf Granath __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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
[R] Set length of axes in lattice's xyplot?
Hello, It is possible to set the aspect ratio of the Y-axis to the X-axis in xyplot (a) xyplot(y~x,aspect=1.8) Suppose I have only 1 panel and i wish to set the length of the X- axis to 2 keeping the same aspect ratio as in (a), I suppose i need to do something in prepanel but what? Is there any function i can call to set the actual length of the axes? Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Set length of axes in lattice
Hello, It is possible to set the aspect ratio of the Y-axis to the X-axis in xyplot (a) xyplot(y~x,aspect=1.8) Suppose I have only 1 panel and i wish to set the length of the X- axis to 2 keeping the same aspect ratio as in (a). I would also like to keep the same scales. I suppose i need to do something in prepanel but what? Is there any function i can call to set the actual length of the axes? Thank you Saptarsho Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha [[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] Re storing a UPDATES on a data.frame
Thank you Prof Brian, this really solved my problem and it was well explained :) Prof Brian Ripley wrote: Well - MASS is a package and not a library - it is not 'base' but 'contributed', and as library(help=MASS) says, support software for a book. It is on CRAN. - Packages with namespaces are read-only, so you have not changed the data frame in MASS, and even for other packages you can only change the copy in memory, not that on disc (all 'unless you know to subvert the standard ways'). What you likely did was to create a new data frame 'whiteside' in your user workspace and then save the workspace containing it. In which case rm(whiteside) save.image() will fix it. However, you should have got warnings about conflicts when you started R, but perhaps you forgot to mention those. Perhaps the following might be educative: library(MASS) find(whiteside) [1] package:MASS whiteside$temp - 1 find(whiteside) [1] .GlobalEnv package:MASS This is really an internal version of whiteside - `$-`(whiteside, temp, 1) and that assigns in the current frame just like any other assignment. On Fri, 15 Feb 2008, savanna3000 wrote: Hello everyone, Can anyone tell me how do I restore data in a data.frame provided by base R libraries (MASS) ? I uninstalled R then installed it again and I still see the new changes I made!!!??? (eg. whiteside$Temp=1 == 1 overwrote all the rows, I want the old values :( !! Please HELP! -- View this message in context: http://www.nabble.com/Restoring-a-UPDATES-on-a-data.frame-tp15512767p15512767.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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Restoring-a-UPDATES-on-a-data.frame-tp15512767p15530584.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] Specify Path of an Excel file in R
Hello Helpers, I have an Excel file on my desktop (.csv) which I want to use in my R worksheet, how can I specify the path while using read.csv() ? Savanna -- View this message in context: http://www.nabble.com/Specify-Path-of-an-Excel-file-in-R-tp15530586p15530586.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] random location in polygons sp spsample splancs csr
Dear all, I had to place points at random, one in each of larger number of polygons (actually in objects of class 'SpatialPolygonsDataFrame' , see sp library), and tried first to do it using spsample (from sp). Surprisingly, every 5-15 trials, the output was a NULL value. The doc says that ' this may occur when trying to hit a small and awkwardly shaped polygon in a large bounding box with a small number of points', but in my case, the shapes were not really awkward, and the bounding box just the smallest rectangle including the shape, just the number of points was 1 in each polygon. Thus I tried csr (from splancs) after having extracted the polygon coordinates of each shape from the Spatial object, and everything went smoothly, with hit success every trial. Has anybody (anybody will probably be Edzer or/and Roger...) an idea why here splancs looks like outperforming spsample ? Patrick __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Specify Path of an Excel file in R
One way that works for lazy people like me is to use file.choose(). 1) Type in file.choose() without the quotes and hit enter 2) Navigate to the folder and file that you want and click on it. 3) R will show you the complete path to your file. An even easier way is to do something like this: my.stuff - read.csv(file.choose(), ... and then navigate to your file. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of savanna3000 Sent: Sunday, February 17, 2008 10:53 AM To: r-help@r-project.org Subject: [R] Specify Path of an Excel file in R Hello Helpers, I have an Excel file on my desktop (.csv) which I want to use in my R worksheet, how can I specify the path while using read.csv() ? Savanna -- View this message in context: http://www.nabble.com/Specify-Path-of-an-Excel-file-in-R-tp15530586p15530586 .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] Transfer Crosstable to Word-Document
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 You can programmatically create content directly in Word from R including tables, lists, paragraphs, etc. via a DCOM connection where R is the client and Word is the server. There are two packages to do this - rcom and RDCOMClient and both allow you to work at much higher levels of specificity than cutting and pasting HTML or CSV content. You'd have to learn a little about the DCOM API for Word, but there are examples. ~ D. [EMAIL PROTECTED] wrote: | # Dear list, | # I am an R-beginner and | # spent the last days looking for a method to insert tables produced | # with R into a word document. I thought about SPPS: copy a table from | # an SPO-file and paste it into a word document | # (if needed do some formatting with that table). | # Annother idea was, to produce a TEX-file, | # insert it and make it a word-table. | | # I found the following libraries, which seemed to be promising: | # xtable | # prettyR | # R2HTML | # Hmisc | # SciViews / svViews | | | | ### | ## My example: a crosstable (made with CrossTable from lib gmodels | ### | | library(gmodels) | library(xtable) | library(svViews) | | # Data for crosstabulation | set.seed(1) | n - 200 | sex - sample(c(f,m),n,T) | state - sample(c(AL,AK,CA),n,T) | | #Create crosstab | ct - CrossTable(state, sex, expected=TRUE, format=SPSS, digits=1) | ct #display crosstab on screen | | #Trie to produce a html file | xtable(ct) #Error message: No method! | methods(xtable) | | | | #Try to create a rich formatted table and insert it into Word | #with svViws, but only a little part of crosstab it inserted | | docdir - r:\\r | WordOpen(file.path(docdir, cross.doc)) | viewfile - view(ct, type = summary, browse = FALSE) | WordGoto(ctview) | WordInsertFile(viewfile, TRUE) #only a little part of crosstab inserted | WordActivate(async = TRUE) | | | #How could I create the latex-code for the crosstable? | w - latex(ct) #would that work? | | # I could not test this, because I didn´t install Miktex yet | # (I will do this soon) | | Can someone help me? | | Thanks in advance | Udo | | | -- | Udo Koenig | Clinic for child and adolescent psychiatry | University of Marburg / Germany | | __ | R-help@r-project.org mailing list | https://stat.ethz.ch/mailman/listinfo/r-help | PLEASE do read the posting guide http://www.R-project.org/posting-guide.html | and provide commented, minimal, self-contained, reproducible code. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHuGsu9p/Jzwa2QP4RAn9xAJ94KmlBA5Yl1hfT4Z0CsmL7s61qpwCfZNhn BMaw4u4FggRWn3QrKg79PAw= =mElZ -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use a reserved word in italics in an expression
Delightfully straightforward! Thanks. On Feb 16, 2008, at 5:15 PM, Duncan Murdoch wrote: On 16/02/2008 4:51 PM, Michael Kubovy wrote: Dear R-helpers, label2 - expression(paste(italic(attraction function:), 'slope')) Error: unexpected 'function' in label2 - expression(paste(italic(attraction function How do I tell R that in this case I don't want 'function' to be treated as a reserved word but as a string in italics? Just put it in quotes. In fact, I think italic(attraction) looks better than italic(attraction), so you may want to do this more generally. For example, plot(1, main=expression(paste(italic(attraction function: ), slope))) Duncan Murdoch _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] History of R
The windows port of R has been very good for a long time. I know some people who even think that the current windows port is better than the Linux version. Thanks to those who have made the windows port available and who continue to maintain it. I now use both MS Windows and Linux (Fedora) and would not like to lose either.. The windows port of Octave before the recent version 3 was not good. As far as I know one was restricted to a very old version or using cygwin. This would not suit most users of windows. Thus Octave was not available to the majority of MS windows users. Compared to R which had the latest version available to Windows users is it any wonder that Octave is not as popular. The new version 3 is a vast improvement and should be looked at by anyone familiar with Matlab. The new front end, using the SciTE editor is a vast improvement on what was previously available. Best Regards John On 16/02/2008, Kathy Gerber [EMAIL PROTECTED] wrote: Thanks to all who responded so thoughtfully. I would like to summarize briefly the observations and opinions so far with some of my own interpretations and thoughts. John Fox is working on a much deeper history scheduled for August, and his three factors are a good starting point. John Fox wrote: Dear Kathy, As Achim has mentioned, I've been doing interviews with members of the R Core team and with some other people central to the R Project. Although I haven't entirely organized and finished reflecting on this material, the following factors come immediately to mind: (1) Doug has already mentioned the personal and technical talents of the original developers, and their generosity in opening up development to a Core group and in making R open source. To that I would add the collective talents of the Core group as a whole. There are three attributes here: a) Personal talent: I take this to mean communication and teaching ability along with leadership. These are the talents and skills that provide groundwork for a mature type of collaboration, more along the lines found in tightly focused academic areas. I would think that these attributes are big factors in why R has not devolved into forks and holy wars. b) Technical talent: Both the technical talent and domain knowledge of the original developers and the R Core group are better than consistently solid. The leaders are not rock stars or cult figures. c) Generosity: The responses themselves sincerely gave credit to others. While this may appear to be consistent with Eric Raymond's notions of open source as built upon a gift culture, I haven't really seen this going on elsewhere at such a level. (2) R implements the S language, which already was in wide use, and which has many attractive features (each of use, etc.). One person who emailed privately pointed out that many open source projects are knock-offs, e.g., linux itself is a unix knock-off. I believe the point is that R is not a totally new approach or invention, rather it is based upon advancing some product or collection of ideas that are already in place. (3) The R package system and the establishment of CRAN allowed literally hundreds of developers to contribute to the broader R Project. More generally, the Core group worked to integrate users into the R Project, e.g., through R News, the r-help list (though naive users aren't always treated gently there), and the useR conferences. Again, this is another distinctive feature, perhaps not in concept but in degree and level of actual success thanks to good planning. Like so many other points, this goes back to the leadership. Another point made was the need or demand for such an application. Yet another was the planning that goes into avoiding breakage of packages. What no one mentioned though was the idea of standards. Finally, in comparing with Octave, it was mentioned that Octave may be stuck in a position of playing catch-up to Matlab. What I have here is far from complete, but I did want to give some feedback tonight. Again, thanks to you all for such articulate responses, and I will point to my slides, and later on write up a summary. Kathy Gerber __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- John C Frain Trinity College Dublin Dublin 2 Ireland www.tcd.ie/Economics/staff/frainj/home.html mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on a computer cluster
Gabriele, In addition to the suggestions from Markus (below), there is NetWorkSpaces (package nws). I have used both nws and snow together with a package I'm developing (bigmemoRy) which allocates matrices to shared memory (helping avoid the bottleneck Markus alluded to for processors on the same computer). Both seem quite easy to use, essentially only needing one command to initiate the cluster and then one command to do something like apply() in parallel. It takes a little planning of your application, but the painfully obvious parallel problem should be painless to implement. Jay Hi, your required performance is strongly depending on your application. If you talk about a cluster, you should think about several computers. Not only one computer with several processors. If you have several computers. First of all you have to decide for a communication protocol for parallel computing: MPI, PVM, ... Then you have to install this at your computers. I think you should use MPI and one of its implementations: OpenMPI, LamMPI Then there are several R packages for using the communication protocols: Rmpi, snow, Rpvm, ... If you have one computer with severals processors, you can do the same thinks. But then you have only shared memory (bottleneck) and there is not to much improvement in performance. R is not yet implemented for multiple-processors. There is one first, experimental R package using openMP for multi threading: pnmath (http://www.stat.uiowa.edu/~luke/R/experimental/) Some useful links: http://www.stats.uwo.ca/faculty/yu/Rmpi/ http://ace.acadiau.ca/math/ACMMaC/Rmpi/ http://www.open-mpi.org/ http://www.personal.leeds.ac.uk/~bgy1mm/MPITutorial/MPIHome.html Best regards Markus [EMAIL PROTECTED] schrieb: Dear all, I usually run R on my laptop with Windows XP Professional. Now I really want to run R on a computer cluster (4 processors) with Suse Linux Enterprise ver. 10. But I am new with computer cluster. Should I modify my functions in order to use the greater performance and availability than that provided by my laptop? Is there any R manual on parallel computations on multiple-processor? Any suggestion on a basic tutorial on this topic? Thank you. -- John W. Emerson (Jay) Assistant Professor of Statistics Director of Graduate Studies Department of Statistics Yale University http://www.stat.yale.edu/~jay REvolution Computing, Statistical Consultant __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Set length of axes in lattice
On 2/17/08, Saptarshi Guha [EMAIL PROTECTED] wrote: Hello, It is possible to set the aspect ratio of the Y-axis to the X-axis in xyplot (a) xyplot(y~x,aspect=1.8) Suppose I have only 1 panel and i wish to set the length of the X- axis to 2 keeping the same aspect ratio as in (a). I would also like to keep the same scales. I suppose i need to do something in prepanel but what? Is there any function i can call to set the actual length of the axes? See ?print.trellis. p - xyplot(1 ~ 1, aspect = 0.5) p plot(p, panel.width = list(2, inches), panel.height = list(1, inches)) This overrides 'aspect=' though, that is, you will need to specify both width and height if you want to control the aspect ratio. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Transfer Crosstable to Word-Document
Zitat von Greg Snow [EMAIL PROTECTED]: If your final goal is a word document, then you should look at the odfWeave package. Greg, I had a look at the odfWeave package, but it seems that complex tables, for instance produced with latex() can´t be produced/included, as can be done with sweave. Udo König Clinic for Child an Adolescent Psychiatry Philipps University of Marburg / Germany __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Set length of axes in lattice
Thank you. On Feb 17, 2008, at 1:18 PM, Deepayan Sarkar wrote: See ?print.trellis. p - xyplot(1 ~ 1, aspect = 0.5) p plot(p, panel.width = list(2, inches), panel.height = list(1, inches)) This overrides 'aspect=' though, that is, you will need to specify both width and height if you want to control the aspect ratio. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] random location in polygons sp spsample splancs csr
Thanks for those detailed explanation and the time taken to write them. The spsample methods for polygons have an iter= argument that can be used to make then try harder, did you try it (with what values - the help page senctence you quote is from the iter= description)? Yes sure, I went up to 10, but no success. Could you provide an example with a set.seed() value that does what you say, or at least the code you used? The easiest way is to send the data and the script off list. I will do it. Did you try asking for multiple points and then choosing a single point at random? This would be equivalent to increasing iter while asking for a single point. I did not try this one Actually, I found my way out easy with csr() in splancs, and did not fight too much with spsample. My question on the list was just for general information PS. Perhaps R-sig-geo is a more appropriate list? I was wondering too... and chose r-help because I though the question was of 'general' interest enough. This is debatable indeed... Thank you anyway for your answer, and see you in a few minutes off list... Cheers, Patrick __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ggplot2: bug in geom_ribbon + log scale!?
Hi everyone, Hadley, it seems there's a bug in geom_ribbon() when using it in a log-scaled plot: d-data.frame(x=c(1:20),y1=rnorm(20)+3,y2=rnorm(20)+5) p-ggplot() p-p+geom_ribbon(data=d,aes(x=d[[x]],min=d[[y1]],max=d[[y2]])) p-p+geom_line(data=d,aes(x=d[[x]],y=d[[y1]]),colour=blue) p-p+geom_line(data=d,aes(x=d[[x]],y=d[[y2]]),colour=red) p2+scale_y_continuous() ...gives the plot I want, only with my actual data, I'd need it in log-scale: p2+scale_y_log10() shifts the ribbon far above the actual data (factor 1000, if I see it right, but I haven't tested it with different data to check on that...). I'm using the latest version of ggplot2 (0.5.7). Has anyone any suggestions for a workaround/patch? Many Thanks, Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 make a vector/list/array of POSIXlt object?
Hi Guys, I'm cooking up my time series code. I want a data frame with first column as timestamp in POSIXlt format. I hit on this the problem of how to create an array/list/vector of POSIXlt objects. Code is as follows dtt=array(dim = 2) t=as.POSIXlt( strptime(07/12/07 13:20:01, %m/%d/%Y %H:%M:%S,tz=GMT)) dtt [1] NA NA t [1] 0007-07-12 13:20:01 GMT dtt[1]=t Warning message: In dtt[1] = t : number of items to replace is not a multiple of replacement length class(dtt) [1] list class(t) [1] POSIXt POSIXlt unclass(t) $sec [1] 1 $min [1] 20 $hour [1] 13 $mday [1] 12 $mon [1] 6 $year [1] -1893 $wday [1] 4 $yday [1] 192 $isdst [1] 0 attr(,tzone) [1] GMT Seems like POSIXlt is matrix in this case. Any suggestions? Cheers, B _ [[elided Hotmail spam]] [[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] Weird SEs with effect()
Dear John and Brian, Thank you for your help. I get the feeling that it is something fundamental that I do not understand here. Furthermore, a day of reading did not really help so maybe we have reached a dead end here. Nevertheless, here comes one last try. I thought that the values produced by effect() were logs (e.g. in $fit). And then they were transformed (antilogged) with summary(). Was I wrong? What I want: I am trying to make a barplot with adjusted means with SEs (error bars), with the y axis labeled on the response scale. #One of my GLM models (inf.level def.level=factors, initial.size = covariate) #used as an example. #I was not able to make a reproducible example though. Sorry. model - glm(tot.fruit~initial.size+inf.level+def.level,family=quasipoisson) summary(model) Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept)1.9368528 0.1057948 18.308 2e-16 *** initial.size 0.0015245 0.0001134 13.443 2e-16 *** inf.level50 -0.3142688 0.0908063 -3.461 0.000612 *** def.level12.5 -0.2329221 0.1236992 -1.883 0.060620 . def.level25 -0.1722354 0.1181993 -1.457 0.146062 def.level50 -0.3543826 0.1212906 -2.922 0.003731 ** (Dispersion parameter for quasipoisson family taken to be 6.431139) Null deviance: 2951.5 on 322 degrees of freedom Residual deviance: 1917.2 on 317 degrees of freedom library(effects) def - effect(def.level,model,se=TRUE) summary(def) $effect def.level 0 12.52550 11.145382 8.829541 9.381970 7.819672 $lower def.level 0 12.5 25 50 9.495220 7.334297 7.867209 6.467627 $upper def.level 0 12.5 25 50 13.08232 10.62962 11.18838 9.45436 #Confidence intervals makes sense and are in line with the glm model result. Now #lets look at the standard errors. Btw, why aren't they given with summary? def$se 324325326327 0.08144281 0.09430438 0.08949864 0.09648573 # As you can see, the SEs are very very very small. #In a graph it would look weird in combination with the glm result. #I thought that these values were logs. Thats why I used exp() which seems to be wrong. Regards, Gustaf Quoting John Fox [EMAIL PROTECTED]: Dear Brian and Gustaf, I too have a bit of trouble following what Gustaf is doing, but I think that Brian's interpretation -- that Gustaf is trying to transform the standard errors via the inverse link rather than transforming the ends of the confidence intervals -- is probably correct. If this is the case, then what Gustaf has done doesn't make sense. It is possible to get standard errors on the scale of the response (using, e.g., the delta method), but it's probably better to work on the scale of the linear predictor anyway. This is what the summary, print, and plot methods in the effects package do (as is documented in the help files for the package -- see the transformation argument under ?effect and the type argument under ?summary.eff). Regards, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: February-17-08 6:42 AM To: Gustaf Granath Cc: John Fox; r-help@r-project.org Subject: Re: [R] Weird SEs with effect() On Sun, 17 Feb 2008, Gustaf Granath wrote: Hi John, In fact I am still a little bit confused because I had read the ?effect help and the archives. ?effect says that the confidence intervals are on the linear predictor scale as well. Using exp() on the untransformed confidence intervals gives me the same values as summary(eff). My confidence intervals seems to be correct and reflects the results from my glm models. But when I use exp() to get the correct SEs on the response scale I get SEs that sometimes do not make sense at all. Interestingly I have What exactly are you doing here? I suspect you are not using the correct formula to transform the SEs (you do not just exponeniate them), but without the reproducible example asked for we cannot tell. found a trend. For my model with adjusted means ~ 0.5-1.5 I get huge SEs (SEs 1, but my glm model shows significant differences between level 1 = 0.55 and level 2 = 1.15). Models with means around 10-20 my SEs are fine with exp(). Models with means around 75-125 my SEs get way too small with exp(). Something is not right here (or maybe they are but I don not understand it) so I think my best option will be to use the confidence intervals instead of SEs in my plot. If you want confidence intervals, you are better off computing those on a reasonable scale and transforming then. Or using a profile likelihood to compute them (which will be equivariant under monotone scale transformations). Regards, Gustaf Quoting
[R] How to create an array/list/vector of POSIXlt objects?
Hi Guys, I'm cooking up my own time series code. I'm creating a data frame with first column as timestamp in POSIXlt format. I'm hit on problems like this dtt=array(dim = 2) t=as.POSIXlt( strptime(07/12/07 13:20:01, %m/%d/%Y %H:%M:%S,tz=GMT)) dtt [1] NA NA t [1] 0007-07-12 13:20:01 GMT dtt[1]=t Warning message: In dtt[1] = t : number of items to replace is not a multiple of replacement length class(dtt) [1] list class(t) [1] POSIXt POSIXlt unclass(t) $sec [1] 1 $min [1] 20 $hour [1] 13 $mday [1] 12 $mon [1] 6 $year [1] -1893 $wday [1] 4 $yday [1] 192 $isdst [1] 0 attr(,tzone) [1] GMT Seems like POSIXlt is a matrix so that it can not be embedded into an element of the array? Any suggestions? Cheers, Bo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 make a vector/list/array of POSIXlt object?
Normally one uses POSIXct rather than POSIXlt for storage. See R News 4/1 for more info on date and time classes. On Feb 17, 2008 3:45 PM, Bo Zhou [EMAIL PROTECTED] wrote: Hi Guys, I'm cooking up my time series code. I want a data frame with first column as timestamp in POSIXlt format. I hit on this the problem of how to create an array/list/vector of POSIXlt objects. Code is as follows dtt=array(dim = 2) t=as.POSIXlt( strptime(07/12/07 13:20:01, %m/%d/%Y %H:%M:%S,tz=GMT)) dtt [1] NA NA t [1] 0007-07-12 13:20:01 GMT dtt[1]=t Warning message: In dtt[1] = t : number of items to replace is not a multiple of replacement length class(dtt) [1] list class(t) [1] POSIXt POSIXlt unclass(t) $sec [1] 1 $min [1] 20 $hour [1] 13 $mday [1] 12 $mon [1] 6 $year [1] -1893 $wday [1] 4 $yday [1] 192 $isdst [1] 0 attr(,tzone) [1] GMT Seems like POSIXlt is matrix in this case. Any suggestions? Cheers, B _ [[elided Hotmail spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] extracting elements by using logical values
dear lists, My question is quite simple but i'm a new user in R and it's seem tough to me. How am i going to recall back my values??ok..it could be easy if i ilustrate my problem with the simple example. say that, x [1] 1 2 y [1] 2 3 and my logical output from my function are (Below is my function): overlapped(x,y) [1] TRUE [1] TRUE suppose i want my output to be: [1] 1 2 [1] 2 3 overlapped-function(x,y){ z-rbind(x,y) for(i in 1:nrow(z)){ overlap-(z[i,1]=z[,2]z[i,2]=z[,1])[-i] if(any(overlap)) print(TRUE) else print(FALSE) } } Thanks in advance!! cheers, Anisah - [[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] difference between lme and lmer in df calculation
Hello all. I'm currently working with mixed models, and have noticed a curious difference between the nlme and lmer packages. While I realize that model selection with mixed models is a tricky issue, the two packages currently produce different AIC scores for the same model, but they systematically differ by 2. In looking at the logLik values for each method, I find that they indeed differ by 1. So, the following code: utils::data(npk, package=MASS) library(lme4) a-lmer(yield ~ 1+(1|block), data=npk) logLik(a) library(nlme) b-lme(yield ~ 1, random=~1|block, data=npk) logLik(b) produces a df of 2 for a, and a df of 3 for b. I'm guessing that lmer is not accounting for the level-1 variance. Is this the case, and, if so, will this be fixed? I see that this issue was brought up sometime back. Is there a reason it has not been addressed? https://stat.ethz.ch/pipermail/r-help/2006-March/102520.html Incidentally, I'm also curious what folk think about the approach to using the conditional AIC value as posted here https://stat.ethz.ch/pipermail/r-help/2008-February/154389.html Thanks! -Jarrett __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ASA Southern California Chapter Applied Statistics Workshop
The Southern California Chapter of the American Statistical Association invites you to attend the 27th annual Applied Statistics Workshop on Friday March 28, 2008 in The Pointe at the Pyramid at California State University, Long Beach. The topic is The Vital Importance of Adjusting for Patient Risk: Risk Adjustment in Health Services Research by Professor Arlene Ash of Boston University. For more information, go to www.sc-asa.org. Early registration deadline is March 11, 2008. Madeline Bauer, Ph.D.University of Southern California Keck School of Medicine (Infectious Diseases) [[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] Custom Plot - means, SD 5th-95th% (Plotmeans or Boxplot)?
Any help with this problem would be greatly appreciated: I need to produce a custom plot i haven't come across in R. Basically, I want to show means, 1st standard deviation and 5th and 95th percentiles visually, using something resembling a boxplot. Is it possible to completely customize a boxplot so that it shows means as the bar (instead of, not as well as medians), standard deviations at the hinges (instead of IQR) and 5th 95th percentiles at the brackets? The plotmeans function (ggplots) allows means to be plotted, but it seems only with confidence intervals, not 5th and 95th percentiles, and also without hinges (for standard deviations). I've searched the forums and various books and have drawn a blank on this. Thanks. Steve Steve Worthington Ph.D. Candidate New York Consortium in Evolutionary Primatology -- View this message in context: http://www.nabble.com/Custom-Plot---means%2C-SD---5th-95th--%28Plotmeans-or-Boxplot%29--tp15537706p15537706.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] Custom Plot - means, SD 5th-95th% (Plotmeans or Boxplot)
It's fairly simple to set up something like this for ggplot2: install.packages(ggplot2) library(ggplot2) library(ggplot2) q5 - function(data) { q - function(p) unname(quantile(data$y, p)) data.frame(min = q(0.05), max = q(0.95)) } ggplot(diamonds, aes(x = cut, y = price)) + stat_summary(fun=mean_sdl, geom=crossbar, mult=1) + stat_summary(fun=q5, geom=linerange) (see Hmisc::smean.sdl for more details on the first summary function). Although from this example you can see that that choice of summary statistics probably isn't the best. You can read more about stat_summary (and ggplot2 in general) at http://had.co.nz/ggplot2/stat_summary.html. Hadley On 2/17/08, Stropharia [EMAIL PROTECTED] wrote: Any help with this problem would be greatly appreciated: I need to produce a custom plot i haven't come across in R. Basically, I want to show means, 1st standard deviation and 5th and 95th percentiles visually, using something resembling a boxplot. Is it possible to completely customize a boxplot so that it shows means as the bar (instead of, not as well as medians), standard deviations at the hinges (instead of IQR) and 5th 95th percentiles at the brackets? The plotmeans function (ggplots) allows means to be plotted, but it seems only with confidence intervals, not 5th and 95th percentiles, and also without hinges (for standard deviations). I've searched the forums and various books and have drawn a blank on this. Thanks. Steve Steve Worthington Ph.D. Candidate New York Consortium in Evolutionary Primatology -- View this message in context: http://www.nabble.com/Custom-Plot---means%2C-SD---5th-95th--%28Plotmeans-or-Boxplot%29--tp15537706p15537706.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. -- 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.
Re: [R] Custom Plot - means, SD 5th-95th% (Plotmeans or Boxplot)
[EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: It's fairly simple to set up something like this for ggplot2: install.packages(ggplot2) library(ggplot2) library(ggplot2) q5 - function(data) { q - function(p) unname(quantile(data$y, p)) data.frame(min = q(0.05), max = q(0.95)) } ggplot(diamonds, aes(x = cut, y = price)) + stat_summary(fun=mean_sdl, geom=crossbar, mult=1) + stat_summary(fun=q5, geom=linerange) On WXP with R2.6.1, and version 0.5.7 of ggplot2, ggplott threw an error whose second line stated that: 'variable stat_q5 of mode function was not found' So I defined stat_q5 with the same function code as q5 above and the plot appeared. I have a follow on ggplot2 question for which I have not found the correct terms for a successful search: how does one change the background fill for the plots? I really would like something other than grey backgrounds and they seem to be the default. -- David Winsemius (see Hmisc::smean.sdl for more details on the first summary function). Although from this example you can see that that choice of summary statistics probably isn't the best. You can read more about stat_summary (and ggplot2 in general) at http://had.co.nz/ggplot2/stat_summary.html. Hadley On 2/17/08, Stropharia [EMAIL PROTECTED] wrote: Any help with this problem would be greatly appreciated: I need to produce a custom plot i haven't come across in R. Basically, I want to show means, 1st standard deviation and 5th and 95th percentiles visually, using something resembling a boxplot. Is it possible to completely customize a boxplot so that it shows means as the bar (instead of, not as well as medians), standard deviations at the hinges (instead of IQR) and 5th 95th percentiles at the brackets? The plotmeans function (ggplots) allows means to be plotted, but it seems only with confidence intervals, not 5th and 95th percentiles, and also without hinges (for standard deviations). I've searched the forums and various books and have drawn a blank on this. Thanks. Steve Steve Worthington Ph.D. Candidate New York Consortium in Evolutionary Primatology -- View this message in context: http://www.nabble.com/Custom-Plot---means%2C-SD---5th-95th--%28Plotm eans-or-Boxplot%29--tp15537706p15537706.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] Custom Plot - means, SD 5th-95th% (Plotmeans or Boxplot)
Using builtin dataset stackloss try this: f - function(x) replace(quantile(x, c(5, 25, 50, 75, 95)/100), 3, mean(x)) bxp(list(stats = sapply(stackloss, f), n = stackloss, names = names(stackloss))) and see ?bxp and ?boxplot On Feb 17, 2008 9:17 PM, Stropharia [EMAIL PROTECTED] wrote: Any help with this problem would be greatly appreciated: I need to produce a custom plot i haven't come across in R. Basically, I want to show means, 1st standard deviation and 5th and 95th percentiles visually, using something resembling a boxplot. Is it possible to completely customize a boxplot so that it shows means as the bar (instead of, not as well as medians), standard deviations at the hinges (instead of IQR) and 5th 95th percentiles at the brackets? The plotmeans function (ggplots) allows means to be plotted, but it seems only with confidence intervals, not 5th and 95th percentiles, and also without hinges (for standard deviations). I've searched the forums and various books and have drawn a blank on this. Thanks. Steve Steve Worthington Ph.D. Candidate New York Consortium in Evolutionary Primatology -- View this message in context: http://www.nabble.com/Custom-Plot---means%2C-SD---5th-95th--%28Plotmeans-or-Boxplot%29--tp15537706p15537706.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to make a vector/list/array of POSIXlt object?
Hi Gabor, I'm using this code but it doesn't work for me strptime2-function (date,time) as.POSIXct(strptime(paste(date,time), %m/%d/%Y %H:%M:%S)) dt=mapply(strptime2, 01/01/2008, 00:00:00, SIMPLIFY=FALSE, USE.NAMES=FALSE) df=data.frame(X1=dt,X2=1) dt [[1]] [1] 2008-01-01 Eastern Standard Time df structure.1199163600..class...c..POSIXtPOSIXcttzone.. X2 12008-01-01 1 Here df looks very wrong to me. So I tested this code: df2=data.frame(X1=as.POSIXct(Sys.time()),X2=1) df2 X1 X2 1 2008-02-17 23:43:08 1 class(df2$X1) [1] POSIXt POSIXct Ah this worked as I expected. So some tweaking here - SIMPLIFY is set TRUE now: strptime2-function (date,time) as.POSIXct(strptime(paste(date,time), %m/%d/%Y %H:%M:%S)) dt=mapply(strptime2, 01/01/2008, 00:00:00, SIMPLIFY=TRUE, USE.NAMES=FALSE) df=data.frame(X1=dt,X2=1) df X1 X2 1 1199163600 1 class(df$X1) [1] numeric Hmm... it worked, but not in a way I wanted. The class info is missing. So how to get the result like this below? I do need that mapply + strptime(paste), cos my CSV file is formatted in that way! df2 X1 X2 1 2008-02-17 23:43:08 1 class(df2$X1) [1] POSIXt POSIXct Any insight? Cheers, Bo Date: Sun, 17 Feb 2008 15:53:28 -0500 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [R] How to make a vector/list/array of POSIXlt object? CC: r-help@r-project.org Normally one uses POSIXct rather than POSIXlt for storage. See R News 4/1 for more info on date and time classes. On Feb 17, 2008 3:45 PM, Bo Zhou [EMAIL PROTECTED] wrote: Hi Guys, I'm cooking up my time series code. I want a data frame with first column as timestamp in POSIXlt format. I hit on this the problem of how to create an array/list/vector of POSIXlt objects. Code is as follows dtt=array(dim = 2) t=as.POSIXlt( strptime(07/12/07 13:20:01, %m/%d/%Y %H:%M:%S,tz=GMT)) dtt [1] NA NA t [1] 0007-07-12 13:20:01 GMT dtt[1]=t Warning message: In dtt[1] = t : number of items to replace is not a multiple of replacement length class(dtt) [1] list class(t) [1] POSIXt POSIXlt unclass(t) $sec [1] 1 $min [1] 20 $hour [1] 13 $mday [1] 12 $mon [1] 6 $year [1] -1893 $wday [1] 4 $yday [1] 192 $isdst [1] 0 attr(,tzone) [1] GMT Seems like POSIXlt is matrix in this case. Any suggestions? Cheers, B _ [[elided Hotmail spam]] [[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. _ Need to know the score, the latest news, or you need your Hotmail®-get your fix. [[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] Odp: Creating a data.frame
Hi [EMAIL PROTECTED] napsal dne 13.02.2008 23:17:32: OK...newbie question here. Either I'm reading the docs wrong, or I'm totally confused. Given the following: x-c(aaa,bbb,ccc) y-rep(0,3) z-rep(0,3) is.character(x) [1] TRUE is.numeric(y) [1] TRUE Now...I want to create a data frame, but keep the data types. In reading the docs, I assume you do it this way: d-data.frame(cbind(x=I(x),y=y,z=z) cbind creates a matrix which has to have all values the same type, in your case character. d-data.frame(x=x,y=y,z=z) will do what you want. Try to find out differences among various types of objects, its pros and cons from some intro documents. Regards Petr But, when I do str(d), I get the following: 'data.frame': 3 obs. of 3 variables: $ x: Factor w/ 3 levels aaa,bbb,ccc: 1 2 3 $ y: Factor w/ 1 level 0: 1 1 1 $ z: Factor w/ 1 level 0: 1 1 1 I thought the I() prevents character from becoming factors, right? Secondly, how do I force y and z in the data frame to become numeric? Thanks in advance Joe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.