Re: [R] How do I calculate r^2 of SSasymp non-linear regression model in R?
zia207 wrote: Is it possible to get r^2 value of SSasymp non-linear regression model in R. See Douglas Bates' comments why the lack of r^2 is a feature, not a bug: http://www.ens.gu.edu.au/ROBERTK/R/HELP/00B/0399.HTML Dieter -- View this message in context: http://n4.nabble.com/How-do-I-calculate-r-2-of-SSasymp-non-linear-regression-model-in-R-tp1008610p1008647.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] question on 'within' and 'parse' commands
Hi, Why can't I pass an expression to `within' by way of textual input to the 'parse' function? e.g., x - data.frame(a=1:5,b=LETTERS[1:5]) x a b 1 1 A 2 2 B 3 3 C 4 4 D 5 5 E within(x, parse(text=a-a*10; b-2:6)) a b 1 1 A 2 2 B 3 3 C 4 4 D 5 5 E within(x, parse(text=a-a*10; b-2:6)[[1]]) a b 1 1 A 2 2 B 3 3 C 4 4 D 5 5 E This would be very useful to allow for arbitrary evaluation of multi-line commands at runtime. Of course, I can edit the 'within.data.frame' function as follows, but isn't there some way to make 'within' more generally like the 'eval' command? alternative: within.data.frame - function (data, textCMD, ...) { parent - parent.frame() e - evalq(environment(), data, parent) eval(parse(text=textCMD), e) # used to be eval(substitute(expr), e) l - as.list(e) l - l[!sapply(l, is.null)] nD - length(del - setdiff(names(data), (nl - names(l data[nl] - l if (nD) data[del] - if (nD == 1) NULL else vector(list, nD) data } --Neil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 on 'within' and 'parse' commands
Hello, parse just parse the text into an expression. parse(text=a-a*10; b-2:6) expression(a-a*10, b-2:6) attr(,srcfile) text If you want to evaluate the expression, you need to call eval y - within(x, eval(parse(text=a-a*10; b-2:6))) y a b 1 10 2 2 20 3 3 30 4 4 40 5 5 50 6 Or you can just do this : y - within(x, { a-a*10; b-2:6 } ) y a b 1 10 2 2 20 3 3 30 4 4 40 5 5 50 6 Romain On 01/07/2010 09:08 AM, N Klepeis wrote: Hi, Why can't I pass an expression to `within' by way of textual input to the 'parse' function? e.g., x - data.frame(a=1:5,b=LETTERS[1:5]) x a b 1 1 A 2 2 B 3 3 C 4 4 D 5 5 E within(x, parse(text=a-a*10; b-2:6)) a b 1 1 A 2 2 B 3 3 C 4 4 D 5 5 E within(x, parse(text=a-a*10; b-2:6)[[1]]) a b 1 1 A 2 2 B 3 3 C 4 4 D 5 5 E This would be very useful to allow for arbitrary evaluation of multi-line commands at runtime. Of course, I can edit the 'within.data.frame' function as follows, but isn't there some way to make 'within' more generally like the 'eval' command? alternative: within.data.frame - function (data, textCMD, ...) { parent - parent.frame() e - evalq(environment(), data, parent) eval(parse(text=textCMD), e) # used to be eval(substitute(expr), e) l - as.list(e) l - l[!sapply(l, is.null)] nD - length(del - setdiff(names(data), (nl - names(l data[nl] - l if (nD) data[del] - if (nD == 1) NULL else vector(list, nD) data } --Neil -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/JFqa : R Journal, Volume 1/2, December 2009 |- http://tr.im/IW9B : C++ exceptions at the R level `- http://tr.im/IlMh : CPP package: exposing C++ objects __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 treating time
There is an alternative through strsplit() when the desired output format is numeric (fractional hours on 0-24 scale). aa - c(3:00,11:42) bb - strsplit(aa,:) bb [[1]] [1] 3 00 [[2]] [1] 11 42 cc - sapply(bb,function(x){as.numeric(x[1])+as.numeric(x[2])/60}) cc [1] 3.0 11.7 AM/PM can be dealt with similarly. aa - c(3:00pm,11:42am) pm - grepl(pm,aa) pm [1] TRUE FALSE bb - strsplit(sub([ap]m$,,aa),:) bb [[1]] [1] 3 00 [[2]] [1] 11 42 cc - sapply(bb,function(x){as.numeric(x[1])+as.numeric(x[2])/60})+12*pm cc [1] 15.0 11.7 Cheers, M. Kulich On 7.1.2010 8:26, Dennis Murphy wrote: Hi: Let x - '3:00' The R package for data that are only dates or only times is chron. For times, it appears that the strings need to be in the form hh:mm:ss on a 24-hour clock, so for example, 1:30 PM should be expressed as 13:30:00. [I didn't see any option for a 12-hour clock with an optional argument to designate AM or PM...if wrong, I'm sure I'll be corrected...] Using the x value above, we have library(chron) times(x) x - '3:00' times(x) Error in convert.times(times., fmt) : format h:m:s may be incorrect In addition: Warning messages: 1: In unpaste(times, sep = fmt$sep, fnames = fmt$periods, nfields = 3) : wrong number of fields in entry(ies) 1 2: In convert.times(times., fmt) : NAs introduced by coercion 3: In convert.times(times., fmt) : NAs introduced by coercion 4: In convert.times(times., fmt) : NAs introduced by coercion So '3:00' isn't enough; we need to add on some seconds... x - paste(x, ':00', sep = '') x [1] 3:00:00 times(x) # Now it works. [1] 03:00:00 To show you that this works equally well with vectors, suppose the input times were a vector z - c('3:00', '4:15', '12:25', '16:41') # Use the same trick as above (paste() is also vectorized).. z - paste(z, ':00', sep = '') times(z) # [1] 03:00:00 04:15:00 12:25:00 16:41:00 Consult ?chron and the examples contained within. You can run the examples on the help page with example(chron). HTH, Dennis On Wed, Jan 6, 2010 at 9:32 PM, chrisli1223 chri...@austwaterenv.com.auwrote: Hi all, I have imported a value 3:00 from Excel into R using read.csv. I want R to recognise it as 3:00am (time data). How do I do it? Thanks in advance, Chris -- View this message in context: http://n4.nabble.com/R-treating-time-tp1008608p1008608.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. -- Michal Kulich, PhD Dept. of Probability and Statistics Charles University Sokolovska 83 186 75 Praha 8 Czech Republic Phone +420-221-913-229 Fax: +420-283-073-341, +420-222-323-316 Email: kul...@karlin.mff.cuni.cz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Finally, the first R spam!
On 1/7/10, David Croll david.cr...@gmx.ch wrote: Just for fun (or concern): I received a R spam mail. Perhaps the first in history... No, not quite first. There was one before on Inference with R, at least. Liviu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] generate XML
Finally, I managed to automatically generate rather simple XML code. In R this is a matrix. The problem concerns how to write that matrix to file. I use write.table and the extension of file .xml Everything works perfect beside coding some language letters (Polish). But the problem disappears when I change the extension to .txt Therefore I write a file with .txt extension and after that I manually change the extension to .xml - it does not solve the problem. Is it possible to write my matrix or txt file to valid xml file? I need to do it automatically. Best, Robert __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building static HTML help pages in R 2.10.x on Windows
On 7.1.2010 9:49, Dieter Menne wrote: Thanks for that code. I fully agree that the current help system is a step back. For stable bookmarking, my workaround is to put options(help.ports=6800) into the profile, so I can created links like http://127.0.0.1:6800/library/gmodels/html/estimable.html but this still required that I start RGui and the help system once. Dieter Thanks for this, too. Btw, is there a way to start the dynamic Rhelp server in the background without manually launching RGui? That, combined with Dieter's suggestion, would bring the help system sort of back to its original state. I am sorry to say that the new dynamic help is a HUGE nuisance to me. Had to revert back to R 2.9 because of that :-(. Michal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Increment in loop - OK
This works. m - matrix(1:3,3,3) x1 - list(m, m+1, m+2, m+3, m+4) out - list() for (i in 1:4){ t[[i]] - Reduce(+, x1[c(i:i+1)]) } Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk Muhammad Rahiz wrote: useRs, I'm getting limited success in trying to apply increment in a loop. The following defined function creates a +1 increment incr - function(x){ eval.parent(substitute(x - x + 1)) print(x) } How do I apply it in a loop on my test dataset, x1, so that the procedure becomes x1[c(1:2)] x1[c(2:3)] x1[c(3:4)] where x1 = m - matrix(1:3,3,3) x1 - list(m, m+1, m+2, m+3, m+4) Thanks. Muhammad __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] generate XML
On 01/07/2010 10:13 AM, Robert wrote: Finally, I managed to automatically generate rather simple XML code. In R this is a matrix. The problem concerns how to write that matrix to file. I use write.table and the extension of file .xml Everything works perfect beside coding some language letters (Polish). But the problem disappears when I change the extension to .txt Therefore I write a file with .txt extension and after that I manually change the extension to .xml - it does not solve the problem. Is it possible to write my matrix or txt file to valid xml file? I need to do it automatically. Best, Robert __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Have you checked the XML package? If you print the matrix within R, this it look like you want (including correct langauge encoding? Because in that case, you probably could use sink (see ?sink). Stephan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] setting different environments
Hallo, I have a set of S4 and S3 classes together in one script. While running this script I create a lot of new functions and objects An example for S3 and S4 classes: ## S3 classes pt - list(x=1,y=2) class(pt) - xypoint xpos - function(x, ...) UseMethod(xpos) xpos.xypoint - function(x) x$x ypos - function(x, ...) UseMethod(ypos) ypos.xypoint - function(x) x$y print.xypoint - function(x) { cat(xypoint\n) cat(x: , xpos(x), y: , ypos(x), \n) } # ## S4 classes setClass(point, representation(x=numeric, y=numeric)) ## Objekt new(point, x=3, y=4) # new(point, x=17, y=5) ## Generics setGeneric(xcoord, function(object) standardGeneric(xcoord)) setGeneric(ycoord, function(object) standardGeneric(ycoord)) setGeneric(showpoint, function(object) standardGeneric(showpoint)) setMethod(xcoord, point, function(object) obj...@x) setMethod(ycoord, point, function(object) obj...@y) setMethod(showpoint, point, function(object) { cat(x=, xcoord(object), , y=, ycoord(object), \n) }) setMethod(show, point, function(object) { showpoint(object) }) setMethod(+, c(point,point), function(e1,e2) { newx - xcoord(e1) + xcoord(e2) newy - ycoord(e1) + ycoord(e2) return(new(point, x=newx, y=newy)) }) setMethod(-, c(point, point), function(e1, e2) { newx - xcoord(e1) - xcoord(e2) newy - ycoord(e1) - ycoord(e2) return(new(point, x=newx, y=newy)) }) setGeneric(point, function(p) standardGeneric(point)) setMethod(f=point, signature=point, definition=function(p) { points(xcoord(p), ycoord(p))}) This two classes creates various functions and objects. This are being saved under .GlobalEnv. My Problem is, that I have a lot of this kind of classes. I would like to know whether or not there is a possibility to put these functions and objects in a different environemnt, so that they won'e be saved under my working directory. Can I save each class in a different environment? How, if possible can I than access this functions? Thanks in advance Assa [[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] generate XML
Dnia 7 stycznia 2010 10:41 S Devriese sdmaill...@gmail.com napisał(a): Have you checked the XML package? If you print the matrix within R, this it look like you want (including correct langauge encoding? Because in that case, you probably could use sink (see ?sink). Stephan Yes. In R I get correct view. How to use sink? I have the object: my.matrix and I want to create a file item1.xml How to do it? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] penalization regression
Dear all, I am using penalization regression method for my data. I am wandering the following names are synonymous or not? Complexity parameter Penalty parameter Shrinkage factor Shrinkage parameter hyper parameter Thanks 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] generate XML
On 01/07/2010 10:57 AM, robert-mcfad...@o2.pl wrote: Dnia 7 stycznia 2010 10:41 S Devriese sdmaill...@gmail.com napisał(a): Have you checked the XML package? If you print the matrix within R, this it look like you want (including correct langauge encoding? Because in that case, you probably could use sink (see ?sink). Stephan Yes. In R I get correct view. How to use sink? I have the object: my.matrix and I want to create a file item1.xml How to do it? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. you might try # open file connection sink(item1.xml) # print object my.matrix # close file connection sink() __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] generate XML
Dnia 7 stycznia 2010 11:30 S Devriese sdmaill...@gmail.com napisał(a): you might try # open file connection sink(item1.xml) # print object my.matrix # close file connection sink() Unfortunately, It does not code letter appropriate. To #print object it's better to use write.table. But thank you for help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding 3D arrows to 3D plots
Eben J. Gering wrote: Greetings, I would like to add 3D arrows (i.e. arrow-headed vectors linking X1Y1Z1 to X2,Y2,Z2) to a 3D plot; ideally the sort of plot that can be rotated interactively. Is this possible using plot3d, or another 3d plotter in R? While it is easy to draw segments in plot3d (e.g. below), I haven't figured out how to add arrow heads, or to create 3d arrows from scratch. ##two headless segments: library(rgl) matrix(1:2,2,3)-segment1 matrix(1:3,2,3)-segment2 plot3d(segment2,type=l,col=red,xlim=c(0,3),ylim=c(0,3),zlim=c(0,3)) plot3d(segment1,type=l,add=TRUE,col=blue) There isn't any current code to do that in rgl, but if you have a particular shape of arrow in mind, you could probably draw it with some combination of functions. The main problem is that I've never seen any very appealing rotatable 3d arrows. There's a Matlab function to draw some here: http://www.mathworks.com/matlabcentral/fileexchange/8396-draw-3d-arrows; it could probably be translated into rgl if you wanted that. 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] Building static HTML help pages in R 2.10.x on Windows
Michal Kulich wrote: On 7.1.2010 9:49, Dieter Menne wrote: Thanks for that code. I fully agree that the current help system is a step back. For stable bookmarking, my workaround is to put options(help.ports=6800) into the profile, so I can created links like http://127.0.0.1:6800/library/gmodels/html/estimable.html but this still required that I start RGui and the help system once. Dieter Thanks for this, too. Btw, is there a way to start the dynamic Rhelp server in the background without manually launching RGui? That, combined with Dieter's suggestion, would bring the help system sort of back to its original state. You don't need Rgui, you could run Rterm, which would have a smaller footprint. It's not very hard to start it and minimize it, but if you want it running invisibly, you'll need to figure out how to hide the icon. A disadvantage of doing this is that you won't see help relevant to your current session, you'll see help relevant to the background task. In 2.10.x there aren't many differences, but you'll find it more limiting in 2.11.x and later. Duncan Murdoch I am sorry to say that the new dynamic help is a HUGE nuisance to me. Had to revert back to R 2.9 because of that :-(. Michal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Calling FING.EXE under RGui.EXE for windows.
I get a problem with shell too: Under Rgui: R.version.string [1] R version 2.10.1 Patched (2010-01-01 r50884) system(C:\\windows\\system32\\find /?, intern = TRUE) character(0) system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE) character(0) shell(C:\\windows\\system32\\find /?) Warning message: In shell(C:\\windows\\system32\\find /?) : 'C:\windows\system32\find /?' execution failed with error code 1 They all work, i.e. they give the required help message, under Rterm and when I issue this from the Windows console it works: C:\windows\system32\find /? 2010/1/7 Uwe Ligges lig...@statistik.tu-dortmund.de: On 07.01.2010 02:04, Gabor Grothendieck wrote: If you have C:\Rtools\bin on your PATH note that it contains a UNIX-like find utility that conflicts with the find utility in Windows. If that is the problem then remove that from your PATH and then run the batch file. The batchfiles distribution at http://batchfiles.googlecode.com has utilities (Rgui.bat, R.bat, Rtools.bat, etc.) that will automatically add C:\Rtools\bin to your path temporarily or only while R is running so that you can leave it off your PATH. I guess it's the use of system() rather than shell() that causes the problem. Under Windows, you have to use shell in order to start a command interpreter. Uwe Ligges On Wed, Jan 6, 2010 at 6:51 PM, John Schexnayderjsc...@us.ibm.com wrote: This is sort of a strange bug. Not show stopping, but annoying. I was wondering if anyone else has noticed this and reported it before I submit a bug report. I noticed while running the RGui and attempting to debug one of my scripts that I encountered a Windows error informing me that Find String [grep] Utility has encountered a problem and needs to close. It is being generated by a call to a DOS batch file which contains a call to Find.exe. It can be reproduced by simply typing System(find) in RGui. What I found strange is that I have been running this script daily without this problem for months. I now realize I never ran that portion of the script while in RGui.exe. It has always run in batch mode which is done by Rterm.exe. I have tried this on three separate machines now all running Windows XP SP3, with versions of R 2.8.1 and R 2.10.1 If executing System(find) under RGui, an error window for the Find String Utility is generated and the command is not exectuted. If the same command is issued in Rterm the expected FIND: Parameter format not correct message is properly returned. It doesn't seem an important bug, but it could be the canary in the mine for a larger problem somewhere down the road. Re, John Schexnayder IBM Tape Manufacturing - Information Technology San Jose, CA 95138 jsc...@us.ibm.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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 treating time
You might check one of the other methods of reading Excel spreadsheets. If you google for R Wiki Excel and then click on Cached (since the R Wiki seems to be down at the moment) various alternatives are listed. On Thu, Jan 7, 2010 at 12:32 AM, chrisli1223 chri...@austwaterenv.com.au wrote: Hi all, I have imported a value 3:00 from Excel into R using read.csv. I want R to recognise it as 3:00am (time data). How do I do it? Thanks in advance, Chris -- View this message in context: http://n4.nabble.com/R-treating-time-tp1008608p1008608.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] table() and setting useNA to be there by default?
Good morning, Is there a way to get table() to default to including NAs - as in... table(..., useNA='ifany') or table(..., useNA='always') or table(..., exclude=NULL) ? I can't see a way under table() or options() or searching the archives (probably using the wrong keyword?). t1 - c(1,2,3,3,3,2,NA,NA,NA,NA) table(t1) t1 1 2 3 1 2 3 I keep forgetting to allow for NAs and I was bitten *again* this morning... ideally I'd like to be able to set a default in my profile so that table(t1) will actually do table(t1, exclude=NULL) or table(t1, useNA='ifany') I could say something like.. tab1 - function(t, ...) { table(t, ..., useNA='ifany') } tab1(t1) t 123 NA 1234 but this names it as 't' instead of 't1' which is ugly? Any other suggestions please? Thanks in advance, Sean O'Riordain Dublin Ireland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Strange behaviour of as.integer()
I have encountered a strange behaviour of as.integer() which does not seem correct to me. Sorry if this is just an indication of me not understanding floating point arithmetic. .57 * 100 [1] 57 .29 * 100 [1] 29 So far, so good. But: as.integer(.57 * 100) [1] 56 as.integer(.29 * 100) [1] 28 Then again: all.equal(.57 * 100, as.integer(57)) [1] TRUE all.equal(.29 * 100, as.integer(29)) [1] TRUE This behaviour is the same in R 2.10.1 (Ubuntu and Windows) and 2.9.2 (Windows), all 32 bit versions. Is this really intended? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Quantreg - 'could not find functionrq'
Hi all, I'm having some troubles with the Quantreg package. I am using R version 2.10.0, and have downloaded the most recent version of Quantreg (4.44) and SparseM (0.83 - required package). However, when I try to run an analysis (e.g. fit1-rq(y~x, tau=0.5)) I get an error message saying that the function rq could not be found. I get the same message when I try to search for any of the other functions that should be in the package (e.g. help(anova.rq)). I used this package last year and still have the old versions of both quantreg and SparseM saved on my machine. When I load these older packages and attempt an analysis (which, incidentally, worked fine last February) I get the same error messages as I do with the new versions. The only think I have changed since last February is the version of R I am using - is there any reason why quantreg wouldn't work in version 2.10.0? I'm not very experienced with R so I'm struggling to work out what may be going wrong - does anyone have any suggestions!? Many thanks Lauren --___ Lauren Gough - Postgraduate Research Student University of Nottingham, School of Geography, Nottingham, NG7 2RD Tel: +44 (0)115 8467052 Email: lgx...@nottingham.ac.uk mailto:lgx...@nottingham.ac.uk P Consider the environment. Please don't print this e-mail unless you really need to. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. [[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] xyplot: adjusting the scale (min, max tick)
Jay wrote: Perfect, that piece of code did exactly what I wanted. However, I stumpled upon a new problem, now my data is plotted on a totally wrong scale. The y-values are all between 160k and 500k, BUT now with that option I find that the plots are between 0 and 50 (?!?). What did I do wrong? This plots the data OK, even thoug it should be between 160k and 500k on the y-scale: xyplot(data1[,2]+data1[,3]~data1[,1], data = data1, type = l, xlab = x, ylab = y, auto.key = list(space=top, lines = T, points = F, text=c(text1, text2)), par.settings = simpleTheme(lty = c(1,2)), scales=list( x=list(alternating=FALSE,tick.number = 11), y=list(limits=c(0,50)) ) ) If I remove the y=list(limits=c(0,50)) the dat is plotted as it should. You probably want something like y = list(at = seq(100, 200, 25), limits = c(100, 200)) Try this: x - 1:20 y1 - rnorm(20)*1e3 y2 - rnorm(20)*1e3 xyplot(y1 + y2 ~ x, type='l', scales = list(y = list( at = seq(-300,400,100), limits = c(-500,500))) ) # or, you could use the ylim argument instead of 'limits=': xyplot(y1 + y2 ~ x, type='l', ylim = c(-500, 500), scales = list(y = list( at = seq(-300,400,100))) ) -Peter Ehlers Peter Ehlers wrote: Have a look at the 'scales' argument. For example: # default plot xyplot(Sepal.Length ~ Petal.Length | Species, data = iris) # modified plot xyplot(Sepal.Length ~ Petal.Length | Species, data = iris, scales=list(y=list(at=c(-5,0,5,10), limits=c(-5,10 -Peter Ehlers Jay wrote: Hi, I'm terribly sorry but it seems it cannot figure this one out by myself so, please, if somebody could help I would be very grateful. So, when I plot with xyplot() I get an y-axis that is very ugly... starting from a random number and having so many ticks that it becomes unreadable. How do I tell xyplot how to draw the axis? E.g., start from 100, end at 200 with 25 units between ticks/labels? Can somebody give me an example? 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. -- Peter Ehlers University of Calgary 403.202.3921 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Ehlers University of Calgary 403.202.3921 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 library(gWidgetsRGtk2) and R2.10.1
Hi all, I've been trying to load the gWidgetsRGtk2 package whith R version 2.10.1 running under Windows XP, but I get the following error message (in french): library(gWidgetsRGtk2) Error in .Call(name, ..., PACKAGE = PACKAGE) : le nom C de symbole S_gtk_icon_factory_new est introuvable dans la DLL pour le package RGtk2 Error : .onAttach a échoué dans 'attachNamespace' Erreur : le chargement du package / espace de noms a échoué pour 'gWidgetsRGtk2' which didn't appeared with previous R versions (I tried it ok with R version 8.1). Any idea? Thanks in advance, Regards Edouard Chatignoux Observatoire Régional de Santé d'Ile-de-France 21-23 Rue Miollis - 75732 PARIS CEDEX 15 Tél. : 01 44 42 64 81 Fax. : 01 44 42 64 71 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Quantreg - 'could not find functionrq'
Are you sure you called library(Quantreg) before calling any function? M. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gough Lauren Sent: Donnerstag, 7. Januar 2010 13:44 To: r-help@r-project.org Subject: [R] Quantreg - 'could not find functionrq' Hi all, I'm having some troubles with the Quantreg package. I am using R version 2.10.0, and have downloaded the most recent version of Quantreg (4.44) and SparseM (0.83 - required package). However, when I try to run an analysis (e.g. fit1-rq(y~x, tau=0.5)) I get an error message saying that the function rq could not be found. I get the same message when I try to search for any of the other functions that should be in the package (e.g. help(anova.rq)). I used this package last year and still have the old versions of both quantreg and SparseM saved on my machine. When I load these older packages and attempt an analysis (which, incidentally, worked fine last February) I get the same error messages as I do with the new versions. The only think I have changed since last February is the version of R I am using - is there any reason why quantreg wouldn't work in version 2.10.0? I'm not very experienced with R so I'm struggling to work out what may be going wrong - does anyone have any suggestions!? Many thanks Lauren --___ Lauren Gough - Postgraduate Research Student University of Nottingham, School of Geography, Nottingham, NG7 2RD Tel: +44 (0)115 8467052 Email: lgx...@nottingham.ac.uk mailto:lgx...@nottingham.ac.uk P Consider the environment. Please don't print this e-mail unless you really need to. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. [[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] Strange behaviour of as.integer()
On 07/01/2010 7:31 AM, Ulrich Keller wrote: I have encountered a strange behaviour of as.integer() which does not seem correct to me. Sorry if this is just an indication of me not understanding floating point arithmetic. .57 * 100 [1] 57 .29 * 100 [1] 29 So far, so good. But: as.integer(.57 * 100) [1] 56 as.integer(.29 * 100) [1] 28 Then again: all.equal(.57 * 100, as.integer(57)) [1] TRUE all.equal(.29 * 100, as.integer(29)) [1] TRUE This behaviour is the same in R 2.10.1 (Ubuntu and Windows) and 2.9.2 (Windows), all 32 bit versions. Is this really intended? Yes, as the man page states, non-integer values are truncated towards zero. Normal printing rounds them. So .57*100, which is slightly less than 57, is rounded to 57 for printing, but is truncated to 56 by as.integer. .57*100 57 [1] TRUE 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] Strange behaviour of as.integer()
On Jan 7, 2010, at 7:31 AM, Ulrich Keller wrote: I have encountered a strange behaviour of as.integer() which does not seem correct to me. Sorry if this is just an indication of me not understanding floating point arithmetic. .57 * 100 [1] 57 .29 * 100 [1] 29 So far, so good. But: as.integer(.57 * 100) [1] 56 as.integer(.29 * 100) [1] 28 From help page for as.integer: Non-integral numeric values are truncated towards zero (i.e., as.integer(x) equals trunc(x) there), Then again: all.equal(.57 * 100, as.integer(57)) [1] TRUE all.equal(.29 * 100, as.integer(29)) [1] TRUE This behaviour is the same in R 2.10.1 (Ubuntu and Windows) and 2.9.2 (Windows), all 32 bit versions. Is this really intended? Yes, it works as documented. -- David Winsemius, MD Heritage Laboratories 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] Odp: Strange behaviour of as.integer()
Hi Maybe FAQ 7.31 strikes again. .57 * 100==as.integer(57) [1] FALSE Regards Petr r-help-boun...@r-project.org napsal dne 07.01.2010 13:31:42: I have encountered a strange behaviour of as.integer() which does not seem correct to me. Sorry if this is just an indication of me not understanding floating point arithmetic. .57 * 100 [1] 57 .29 * 100 [1] 29 So far, so good. But: as.integer(.57 * 100) [1] 56 as.integer(.29 * 100) [1] 28 Then again: all.equal(.57 * 100, as.integer(57)) [1] TRUE all.equal(.29 * 100, as.integer(29)) [1] TRUE This behaviour is the same in R 2.10.1 (Ubuntu and Windows) and 2.9.2 (Windows), all 32 bit versions. Is this really intended? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Quantreg - 'could not find functionrq'
On Jan 7, 2010, at 8:07 AM, Meyners, Michael, LAUSANNE, AppliedMathematics wrote: Are you sure you called library(Quantreg) before calling any function? M. Are you both using a package with the exact spelling Quantreg? I would have expected it to be : library(quantreg) -- David. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gough Lauren Sent: Donnerstag, 7. Januar 2010 13:44 To: r-help@r-project.org Subject: [R] Quantreg - 'could not find functionrq' Hi all, I'm having some troubles with the Quantreg package. I am using R version 2.10.0, and have downloaded the most recent version of Quantreg (4.44) and SparseM (0.83 - required package). However, when I try to run an analysis (e.g. fit1-rq(y~x, tau=0.5)) I get an error message saying that the function rq could not be found. I get the same message when I try to search for any of the other functions that should be in the package (e.g. help(anova.rq)). I used this package last year and still have the old versions of both quantreg and SparseM saved on my machine. When I load these older packages and attempt an analysis (which, incidentally, worked fine last February) I get the same error messages as I do with the new versions. The only think I have changed since last February is the version of R I am using - is there any reason why quantreg wouldn't work in version 2.10.0? I'm not very experienced with R so I'm struggling to work out what may be going wrong - does anyone have any suggestions!? Many thanks Lauren --___ Lauren Gough - Postgraduate Research Student University of Nottingham, School of Geography, Nottingham, NG7 2RD Tel: +44 (0)115 8467052 Email: lgx...@nottingham.ac.uk mailto:lgx...@nottingham.ac.uk P Consider the environment. Please don't print this e-mail unless you really need to. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. [[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. David Winsemius, MD Heritage Laboratories 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] Quantreg - 'could not find functionrq'
Frankly, I have never even heard about this package before and have no clue what it does, but the error messages nevertheless suggested a missing call of library. And I didn't bother to check the spelling, my fault. So I guess you are right... I still didn't check :-) So to the OP: try library(asdf) with asdf replaced by the correct package name, and mind the spelling! Michael -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Donnerstag, 7. Januar 2010 14:22 To: Meyners,Michael,LAUSANNE,AppliedMathematics Cc: Gough Lauren; r-help@r-project.org Subject: Re: [R] Quantreg - 'could not find functionrq' On Jan 7, 2010, at 8:07 AM, Meyners, Michael, LAUSANNE, AppliedMathematics wrote: Are you sure you called library(Quantreg) before calling any function? M. Are you both using a package with the exact spelling Quantreg? I would have expected it to be : library(quantreg) -- David. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gough Lauren Sent: Donnerstag, 7. Januar 2010 13:44 To: r-help@r-project.org Subject: [R] Quantreg - 'could not find functionrq' Hi all, I'm having some troubles with the Quantreg package. I am using R version 2.10.0, and have downloaded the most recent version of Quantreg (4.44) and SparseM (0.83 - required package). However, when I try to run an analysis (e.g. fit1-rq(y~x, tau=0.5)) I get an error message saying that the function rq could not be found. I get the same message when I try to search for any of the other functions that should be in the package (e.g. help(anova.rq)). I used this package last year and still have the old versions of both quantreg and SparseM saved on my machine. When I load these older packages and attempt an analysis (which, incidentally, worked fine last February) I get the same error messages as I do with the new versions. The only think I have changed since last February is the version of R I am using - is there any reason why quantreg wouldn't work in version 2.10.0? I'm not very experienced with R so I'm struggling to work out what may be going wrong - does anyone have any suggestions!? Many thanks Lauren --___ Lauren Gough - Postgraduate Research Student University of Nottingham, School of Geography, Nottingham, NG7 2RD Tel: +44 (0)115 8467052 Email: lgx...@nottingham.ac.uk mailto:lgx...@nottingham.ac.uk P Consider the environment. Please don't print this e-mail unless you really need to. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. [[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. David Winsemius, MD Heritage Laboratories 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] vectors into a matrix
Hello all, Firstly, thanks a lot for all your efforts, the cbind function was very useful. I tried all you told me, but I couldn't make it work in the way I wanted. I mixed two problems I had, a common mistake. Sorry if I didn't explain myself good enough. Here, I post a solution for my problem. I wanted to avoid the while loop but I've finally used it. Hopefully it is helpfull for someone else. CODE: --- # This could be my data: VD1 - c(12, 34, 45, 7, 67, 45) VD2 - c(23, 12, 45, 67, 89, 90) VD3 - c(14, 11, 10, 19, 20, 27) VD4 - c(16, 22, 23, 29, 27, 28) # and this is my objective: # (in this case it is just for 4 vectors) AIM - matrix(c(VD1, VD2, VD3, VD4), nrow=4, byrow=TRUE) print(AIM) # but I want to use any number of vectors # VDx when x goes from 1 to n n - 4 # for this case. # A solution: # build an empty matrix with the desired number of rows (vectors) # then with a while loop fill each row with each vector. Final.matrix - matrix(, nrow=n, ncol=6, byrow=TRUE) print(Final.matrix) y - 1 while (y = n) { c - eval(parse(text=(paste(VD, sep=, y Final.matrix[y,] - c y - y + 1 } print(Final.matrix) # If I set n as 12 I will get the example I explained at first # then, by using cbind() and 1:n I add the values of the first column # as many of you suggested to me --- If someone comes up with a way to do this avoiding the loop, I'd be very interested to get to know the solution. Kind regards, Vilen Forestry Engineer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 report or correct translations typos?
Hi R users and developers: Thanks to Mr Pablo Emilio Verde for his constribution to the spanish translation for R messages he makes a very good job. I find a tiny typo on the translation, in particular on the es.po file line 7312 it says: pueto it should be: puerto How can anybody might correct a typo or which is the best way to correct it on a future patch? Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] table() and setting useNA to be there by default?
Sean O'Riordain wrote: Good morning, Is there a way to get table() to default to including NAs - as in... table(..., useNA='ifany') or table(..., useNA='always') or table(..., exclude=NULL) ? I can't see a way under table() or options() or searching the archives (probably using the wrong keyword?). t1 - c(1,2,3,3,3,2,NA,NA,NA,NA) table(t1) t1 1 2 3 1 2 3 I keep forgetting to allow for NAs and I was bitten *again* this morning... ideally I'd like to be able to set a default in my profile so that table(t1) will actually do table(t1, exclude=NULL) or table(t1, useNA='ifany') I could say something like.. tab1 - function(t, ...) { table(t, ..., useNA='ifany') } tab1(t1) t 123 NA 1234 but this names it as 't' instead of 't1' which is ugly? How about tab1 - function(...) table(..., useNA='ifany') -Peter Ehlers Any other suggestions please? Thanks in advance, Sean O'Riordain Dublin Ireland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Ehlers University of Calgary 403.202.3921 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building static HTML help pages in R 2.10.x on Windows
Michal Kulich wrote: On 7.1.2010 9:49, Dieter Menne wrote: I am sorry to say that the new dynamic help is a HUGE nuisance to me. Had to revert back to R 2.9 because of that :-(. Michal I too have reverted to 2.9.2 on Win XP because I find html help to be far less convenient than the compiled CHM help I had before. CHM help is so much easier because the Contents, Index and Search panels make it easy to *see* all the items defined for a package, and I get a separate help window for each package. I very much appreciate the efforts of the R-core team to move R forward, but I think the change in help is a step back. -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] vectors into a matrix
you could try something like this: VD1 - c(12, 34, 45, 7, 67, 45) VD2 - c(23, 12, 45, 67, 89, 90) VD3 - c(14, 11, 10, 19, 20, 27) VD4 - c(16, 22, 23, 29, 27, 28) n - 4 do.call(rbind, lapply(paste(VD, 1:n, sep = ), get)) I hope it helps. Best, Dimitris varend...@gmail.com wrote: Hello all, Firstly, thanks a lot for all your efforts, the cbind function was very useful. I tried all you told me, but I couldn't make it work in the way I wanted. I mixed two problems I had, a common mistake. Sorry if I didn't explain myself good enough. Here, I post a solution for my problem. I wanted to avoid the while loop but I've finally used it. Hopefully it is helpfull for someone else. CODE: --- # This could be my data: VD1 - c(12, 34, 45, 7, 67, 45) VD2 - c(23, 12, 45, 67, 89, 90) VD3 - c(14, 11, 10, 19, 20, 27) VD4 - c(16, 22, 23, 29, 27, 28) # and this is my objective: # (in this case it is just for 4 vectors) AIM - matrix(c(VD1, VD2, VD3, VD4), nrow=4, byrow=TRUE) print(AIM) # but I want to use any number of vectors # VDx when x goes from 1 to n n - 4 # for this case. # A solution: # build an empty matrix with the desired number of rows (vectors) # then with a while loop fill each row with each vector. Final.matrix - matrix(, nrow=n, ncol=6, byrow=TRUE) print(Final.matrix) y - 1 while (y = n) { c - eval(parse(text=(paste(VD, sep=, y Final.matrix[y,] - c y - y + 1 } print(Final.matrix) # If I set n as 12 I will get the example I explained at first # then, by using cbind() and 1:n I add the values of the first column # as many of you suggested to me --- If someone comes up with a way to do this avoiding the loop, I'd be very interested to get to know the solution. Kind regards, Vilen Forestry Engineer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Naming functions for the purpose of profiling
I wanted to send an update on my exploits in trying to get rid of Anonymous entries in my Rprof.out file (see my prior mail below). Basically, I have now found a way to dynamically name a function, and even if it is not the cleanest way, I think it will help me in some of my profiling needs, and may help others as well. I'm including some demonstration code that addresses the issues I wanted to solve: ## # Demonstration of function names in profiling output a.func - function() for (i in 1:100) b = 100^100 # Here, the function name ends up in Rprof.out # (This is the straight-forward example) Rprof(Rprof-simple-a.out) a.func() Rprof(NULL) # This doesn't work # (Function shows up as 'Anonymous' in Rprof.out) b = list() b$func = a.func Rprof(Rprof-simple-b.out) b$func() Rprof(NULL) # By assigning to a variable, the anonymous function gets an # explicit name (Function shows up as 'c.func' in Rprof.out) c.func = b$func Rprof(Rprof-simple-c.out) c.func() Rprof(NULL) # This example is a bit contrived, but works nevertheless # The anonymous function is assigned to an explicit variable, # but the variable name can by generated dynamically # (Function shows up as 'd.func' in Rprof.out, and the stack # also includes calls to 'eval' as expected) d = list() d$func = b$func Rprof(Rprof-simple-d.out) desired.func.name = d.func eval(parse(text=paste( desired.func.name, = d$func; ,desired.func.name,(), sep=))) Rprof(NULL) ## And thanks to Jim Holtman who contacted me off-line and gave me some helpful advice on profiling in general. Best, Magnus On 1/5/2010 2:58 PM, Magnus Torfason wrote: Hi all, I have some long-running code that I'm trying to profile. I am seeing a lot of time spent inside the Anonymous function. Of course, this can in fact be any of several functions, but I am unable to see how I could use the information from Rprof.out to discern which function is taking the most time. An example line from my Rprof.out is: rbernoulli Anonymous runOneRound FUN lapply sfLapply doTryCatch tryCatchOne tryCatchList tryCatch try eval.with.vis eval.with.vis source In my case, the Anonymous functions seem to be any of several work-horse functions, that are part of a list, and different cases are dispatched to different functions. I could of course get them all out of the list and rewrite the dispatch code, but that does not seem like a neat way do address this. So I am wondering if there is any way to explicitly set the name of a function in a way that leads to it being picked up by the profiler? The same problem seems to apply to Anonymous functions that are generated on the fly in an apply call or elsewhere. Of course, having source files and line numbers included in the profiling output would solve this issue, but it seems to me that R probably does not have any awareness of where a function was written down (and of course, even the text of a function can be constructed dynamically within a program). So I guess that is not a viable approach. Thanks in advance for any help on this, and any pointers on the best references for advanced profiling issues would be appreciated as well (I know of summaryRprof of course, but it can be difficult to get the full picture from the summaryRprof output if the calling structure is complicated). Best, Magnus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 report or correct translations typos?
On 07/01/2010 9:04 AM, Kenneth Roy Cabrera Torres wrote: Hi R users and developers: Thanks to Mr Pablo Emilio Verde for his constribution to the spanish translation for R messages he makes a very good job. I find a tiny typo on the translation, in particular on the es.po file line 7312 it says: pueto it should be: puerto How can anybody might correct a typo or which is the best way to correct it on a future patch? You can see the translation teams listed on http://developer.r-project.org/TranslationTeams.html. You send your corrections to them (as you have already done; this message is just to confirm you've done what you should do). Duncan Murdoch Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Extract p-value from linear model
Dear all, I have the following question. Is it possible in R to call for the p-value directly in a model like this a - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) b - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) summary(lm(a~(b+0))) or even in this a - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) b - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) summary(lm(a~b)) to call the p-values directly for every estimated parameter. Thanks a lot for the help! [[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 report or correct translations typos? [SOLVED]
Thank you Dr. Murdoch. El jue, 07-01-2010 a las 09:12 -0500, Duncan Murdoch escribió: On 07/01/2010 9:04 AM, Kenneth Roy Cabrera Torres wrote: Hi R users and developers: Thanks to Mr Pablo Emilio Verde for his constribution to the spanish translation for R messages he makes a very good job. I find a tiny typo on the translation, in particular on the es.po file line 7312 it says: pueto it should be: puerto How can anybody might correct a typo or which is the best way to correct it on a future patch? You can see the translation teams listed on http://developer.r-project.org/TranslationTeams.html. You send your corrections to them (as you have already done; this message is just to confirm you've done what you should do). Duncan Murdoch Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] vectors into a matrix
On Jan 7, 2010, at 8:03 AM, varend...@gmail.com wrote: Hello all, Firstly, thanks a lot for all your efforts, the cbind function was very useful. I tried all you told me, but I couldn't make it work in the way I wanted. I mixed two problems I had, a common mistake. Sorry if I didn't explain myself good enough. Here, I post a solution for my problem. I wanted to avoid the while loop but I've finally used it. Hopefully it is helpfull for someone else. CODE: --- # This could be my data: VD1 - c(12, 34, 45, 7, 67, 45) VD2 - c(23, 12, 45, 67, 89, 90) VD3 - c(14, 11, 10, 19, 20, 27) VD4 - c(16, 22, 23, 29, 27, 28) # and this is my objective: # (in this case it is just for 4 vectors) AIM - matrix(c(VD1, VD2, VD3, VD4), nrow=4, byrow=TRUE) print(AIM) # but I want to use any number of vectors # VDx when x goes from 1 to n n - 4 # for this case. # A solution: # build an empty matrix with the desired number of rows (vectors) # then with a while loop fill each row with each vector. Final.matrix - matrix(, nrow=n, ncol=6, byrow=TRUE) print(Final.matrix) y - 1 while (y = n) { c - eval(parse(text=(paste(VD, sep=, y Final.matrix[y,] - c y - y + 1 } print(Final.matrix) # If I set n as 12 I will get the example I explained at first # then, by using cbind() and 1:n I add the values of the first column # as many of you suggested to me --- If someone comes up with a way to do this avoiding the loop, I'd be very interested to get to know the solution. Kind regards, Vilen Forestry Engineer library(fortunes) fortune(parse) If the answer is parse() you should usually rethink the question. -- Thomas Lumley R-help (February 2005) An easier way is to use get() along with ls(), using a regex pattern in the latter. That will get you the objects which you can then manipulate as desired. # see ?regex ls(pattern = ^VD[0-9]+$) [1] VD1 VD2 VD3 VD4 # This presumes that each vector is the same length, such that using sapply() will return a matrix rather than a list. t(sapply(ls(pattern = ^VD[0-9]+$), get)) [,1] [,2] [,3] [,4] [,5] [,6] VD1 12 34 457 67 45 VD2 23 12 45 67 89 90 VD3 14 11 10 19 20 27 VD4 16 22 23 29 27 28 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] Building static HTML help pages in R 2.10.x on Windows
On 07/01/2010 9:05 AM, Michael Friendly wrote: Michal Kulich wrote: On 7.1.2010 9:49, Dieter Menne wrote: I am sorry to say that the new dynamic help is a HUGE nuisance to me. Had to revert back to R 2.9 because of that :-(. Michal I too have reverted to 2.9.2 on Win XP because I find html help to be far less convenient than the compiled CHM help I had before. CHM help is so much easier because the Contents, Index and Search panels make it easy to *see* all the items defined for a package, and I get a separate help window for each package. I very much appreciate the efforts of the R-core team to move R forward, but I think the change in help is a step back. You can see the items for the package on the index page for the package, which is linked from every page. You can put together a package that displays the help in your favourite format, if you don't like the default format. There's nothing that we used in CHM help that couldn't be duplicated in Javascript, without the security holes. I see it as more important that R core enables others to do what they want, rather than to maintain ancient designs. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] diag, diag- and [ , [-
Dear all I have the following problem. M - matrix(0,3,3) # dimension of M is dinamic and this can lead to the next subscript diag(M[1,1]) - rep(100,1) #Error in `diag-`(`*tmp*`, value = 100) : # only matrix diagonals can be replaced diag(M[1,1,drop=F]) - rep(100,1) #Error in diag(M[1, 1, drop = F]) - rep(100, 1) : # incorrect number of subscripts diag(M[2:3,1:2]) - rep(100,2) # works fine Is there a way to usw diag as replacement function when the input matrix is subscript to a one by one matrix. I don't want extra if(dim==1)... etc. Thanks a lot in advance. Best regards, Roger [[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] Extract p-value from linear model
coef(summary(lm(..stuff..)))[,4] or coef(summary(lm(..stuff..)))[,4,drop=FALSE] -Peter Ehlers Trafim Vanishek wrote: Dear all, I have the following question. Is it possible in R to call for the p-value directly in a model like this a - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) b - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) summary(lm(a~(b+0))) or even in this a - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) b - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) summary(lm(a~b)) to call the p-values directly for every estimated parameter. Thanks a lot for the help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Ehlers University of Calgary 403.202.3921 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extract p-value from linear model
On 07-Jan-10 14:15:07, Trafim Vanishek wrote: Dear all, I have the following question. Is it possible in R to call for the p-value directly in a model like this a - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) b - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) summary(lm(a~(b+0))) summary(lm(a~(b+0))) # [...] # Coefficients: # Estimate Std. Error t value Pr(|t|) # b 0.907770.07134 12.72 4.67e-07 *** # --- summary(lm(a~(b+0)))$coef[,4] # [1] 4.665795e-07 or even in this a - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) b - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) summary(lm(a~b)) to call the p-values directly for every estimated parameter. Thanks a lot for the help! summary(lm(a~b)) # [...] # Coefficients: # Estimate Std. Error t value Pr(|t|) # (Intercept) 7.7957 2.1661 3.599 0.00699 ** # b-0.6230 0.4279 -1.456 0.18351 # --- summary(lm(a~b))$coef[,4] # (Intercept) b # 0.006992306 0.183511560 Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 07-Jan-10 Time: 14:39: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] Building static HTML help pages in R 2.10.x on Windows
On 7.1.2010 12:18, Duncan Murdoch wrote: You don't need Rgui, you could run Rterm, which would have a smaller footprint. It's not very hard to start it and minimize it, but if you want it running invisibly, you'll need to figure out how to hide the icon. This works. Not entirely invisible but not a big deal about that. The R code run within Rterm is options(help_type=html,help.ports=6800) help.start() library(audio) wait(-1) [couldn't find another way to hang R indefinitely in batch mode] A disadvantage of doing this is that you won't see help relevant to your current session, you'll see help relevant to the background task. In 2.10.x there aren't many differences, but you'll find it more limiting in 2.11.x and later. Not a problem if one is not switching between different versions of R. The current version is on the path and the path will get updated (manually) after a new version is installed. Thus, the relevant help will be always displayed. Thanks, this is a kind of solution. Now I can use bookmarks to HTML help for the favorite libraries when working in ESS - the impossibility to set those and the need to start Rgui was the big nuisance. I am sure the new help system will get gradually improved in the future. Best, Michal -- Michal Kulich, PhD Dept. of Probability and Statistics Charles University Sokolovska 83 186 75 Praha 8 Czech Republic Email: kul...@karlin.mff.cuni.cz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building static HTML help pages in R 2.10.x on Windows
On Thu, Jan 7, 2010 at 9:20 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 07/01/2010 9:05 AM, Michael Friendly wrote: Michal Kulich wrote: On 7.1.2010 9:49, Dieter Menne wrote: I am sorry to say that the new dynamic help is a HUGE nuisance to me. Had to revert back to R 2.9 because of that :-(. Michal I too have reverted to 2.9.2 on Win XP because I find html help to be far less convenient than the compiled CHM help I had before. CHM help is so much easier because the Contents, Index and Search panels make it easy to *see* all the items defined for a package, and I get a separate help window for each package. I very much appreciate the efforts of the R-core team to move R forward, but I think the change in help is a step back. You can see the items for the package on the index page for the package, which is linked from every page. You can put together a package that displays the help in your favourite format, if you don't like the default format. There's nothing that we used in CHM help that couldn't be duplicated in Javascript, without the security holes. I see it as more important that R core enables others to do what they want, rather than to maintain ancient designs. Perhaps the link to the Index could be placed at both the top and bottom rather than just at the bottom since its a nuisance to have to scroll down and its less noticeable at the bottom as its typically off the screen. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] diag, diag- and [ , [-
On 07/01/2010 9:31 AM, berga...@gmail.com wrote: Dear all I have the following problem. M - matrix(0,3,3) # dimension of M is dinamic and this can lead to the next subscript diag(M[1,1]) - rep(100,1) #Error in `diag-`(`*tmp*`, value = 100) : # only matrix diagonals can be replaced diag(M[1,1,drop=F]) - rep(100,1) #Error in diag(M[1, 1, drop = F]) - rep(100, 1) : # incorrect number of subscripts diag(M[2:3,1:2]) - rep(100,2) # works fine Is there a way to usw diag as replacement function when the input matrix is subscript to a one by one matrix. I don't want extra if(dim==1)... etc. The problem isn't with diag, it's with [-. When you include drop=F, it doesn't appear to handle properly the matrix indexing that diag() uses. So a simpler example is just M[1,1, drop=FALSE] - 1 which generates the same error you saw. I'd call this a bug; I'll look into it. ([- is done internally in some fairly ugly code, so this might take a while.) As a workaround, I think this does what you want: n - 1 submatrix - M[1:n,1:n,drop=FALSE] diag(submatrix) - rep(100, n) M[1:n,1:n] - submatrix Duncan Murdoch Thanks a lot in advance. Best regards, Roger [[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] Building static HTML help pages in R 2.10.x on Windows
On 7.1.2010 15:52, Duncan Murdoch wrote: Not necessarily. The current help system can display information about the current session, e.g. the result of ls(), as a simple example. But if you use a single background session you won't get relevant information. Duncan Murdoch Sorry, I must admit I don't get it. -- Michal Kulich, PhD Dept. of Probability and Statistics Charles University Sokolovska 83 186 75 Praha 8 Czech Republic Email: kul...@karlin.mff.cuni.cz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building static HTML help pages in R 2.10.x on Windows
On 07/01/2010 9:47 AM, Michal Kulich wrote: On 7.1.2010 12:18, Duncan Murdoch wrote: You don't need Rgui, you could run Rterm, which would have a smaller footprint. It's not very hard to start it and minimize it, but if you want it running invisibly, you'll need to figure out how to hide the icon. This works. Not entirely invisible but not a big deal about that. The R code run within Rterm is options(help_type=html,help.ports=6800) help.start() library(audio) wait(-1) [couldn't find another way to hang R indefinitely in batch mode] A disadvantage of doing this is that you won't see help relevant to your current session, you'll see help relevant to the background task. In 2.10.x there aren't many differences, but you'll find it more limiting in 2.11.x and later. Not a problem if one is not switching between different versions of R. The current version is on the path and the path will get updated (manually) after a new version is installed. Thus, the relevant help will be always displayed. Not necessarily. The current help system can display information about the current session, e.g. the result of ls(), as a simple example. But if you use a single background session you won't get relevant information. Duncan Murdoch Thanks, this is a kind of solution. Now I can use bookmarks to HTML help for the favorite libraries when working in ESS - the impossibility to set those and the need to start Rgui was the big nuisance. I am sure the new help system will get gradually improved in the future. Best, Michal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] kriging with geoR package
Hi all, I have to draw a map of microorganisms repartition in a sample. I use the image function of geoR package to build the map but there are three problems: 1) the legend is Horizontal (with or without vert.leg=TRUE) 2) I want to plot the position of organisms and level curves of density on the map but I don't find the script to insert these data on the map. 3)the grey range are not really represented on the map: I don't have gradual evolution but only patches This is the script I use, can you help me on these three points??? image(KC,col=gray[0:5],xlim=c(-1,53),ylim=c(0,53),x.leg=c(51,53),y.leg=c(10,40),vert.leg=T,pch=°) If necessary I can give further informations about my script. I thank you all for your answers. -- View this message in context: http://n4.nabble.com/kriging-with-geoR-package-tp1008696p1008696.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building static HTML help pages in R 2.10.x on Windows
On 07/01/2010 9:51 AM, Gabor Grothendieck wrote: On Thu, Jan 7, 2010 at 9:20 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 07/01/2010 9:05 AM, Michael Friendly wrote: Michal Kulich wrote: On 7.1.2010 9:49, Dieter Menne wrote: I am sorry to say that the new dynamic help is a HUGE nuisance to me. Had to revert back to R 2.9 because of that :-(. Michal I too have reverted to 2.9.2 on Win XP because I find html help to be far less convenient than the compiled CHM help I had before. CHM help is so much easier because the Contents, Index and Search panels make it easy to *see* all the items defined for a package, and I get a separate help window for each package. I very much appreciate the efforts of the R-core team to move R forward, but I think the change in help is a step back. You can see the items for the package on the index page for the package, which is linked from every page. You can put together a package that displays the help in your favourite format, if you don't like the default format. There's nothing that we used in CHM help that couldn't be duplicated in Javascript, without the security holes. I see it as more important that R core enables others to do what they want, rather than to maintain ancient designs. Perhaps the link to the Index could be placed at both the top and bottom rather than just at the bottom since its a nuisance to have to scroll down and its less noticeable at the bottom as its typically off the screen. Yes, I may do that at some point, to make the layout of the help pages more consistent. Most higher level pages have a consistent header (more so in R-devel), but the individual topic pages don't. What I'd really like is for someone who has good taste to redesign the look of the whole system. I think one or two people are working on packages to do this, and I'd much rather spend time providing whatever low level support they need, rather than doing it myself. 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] Strange behaviour of as.integer()
There have been some really great responses to this question. I would like to make a minor contribution by throwing the 'gmp' package into the mix. On 1/7/2010 8:12 AM, Duncan Murdoch wrote: On 07/01/2010 7:31 AM, Ulrich Keller wrote: as.integer(.57 * 100) [1] 56 Yes, as the man page states, non-integer values are truncated towards zero. .57*100 57 [1] TRUE gmp provides the bigz and bigq classes which provide arbitrary precision integers and rationals, and would solve Ulrich's original problem quite effectively: library(gmp) # bigq will not parse 0.57 but writing such a parser # would be a trivial extension. x = as.bigq(57)/100 x [1] 57/100 # as.integer(x*100) does not seem to be overloaded correctly, so # we need to use as.numeric first, but the end result is 57 as.integer(as.numeric(x*100)) [1] 57 # And we conclude by making some comparisons, and finding the that # the results are what a fifth-grader would expect, rather than # what a CS grad would expect :-) x*10057 [1] FALSE x*100==57 [1] TRUE Of course there is still the problem that: 1+1 == sqrt(2)*sqrt(2) [1] FALSE and gmp will not solve this . I don't know if there is an R-package for arbitrary-precision reals floating around, but probably not. However, Wolfram Alpha will return the correct answer: http://tr.im/1plus1equals2 Best, Magnus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] building a neural network on a unbalanced data set on R
Hello everybody, I work in a production plant as an operations analyst. I have been using R for two years, starting with my final dissertation project at college. We have the following problem in our plant. At the end of the production process, each joint (that is what we produce) must pass a final electrical test. The result can be 0 or 1. We think that this may depend on some raw materials parameters, so at first we have built a logistic regression model in order to make some forecasts. Now I would like to try with a neural network as well. Of course I would like to set the output response as logistic. But the values fitted on the training set turn out to be all 1s. I think that this depends on the following matter. The training data set is made up of 14 0s and 54 1s: so it is quite unbalanced. The net by default classifies as 1 all observations whose probability of success is greater than 0.5. I think that it would be enough to raise the cut-off probability to 0.79, as it is the fraction of 1s over the entire data set (54/68). So, a joint should be classified as 1 only if its probability is larger than 0.79. The problem is that I cannot find out how to set this threshold using the R command nnet. Do you have any ideas? Thank you very much. Kind regards. Enrico Giorgi _ [[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] mean for subset
As a novice R user, I face a similar challenge. I am almost afraid to share with this group how I solved it. About 65 labs in our proficiency program submit data on individual Excel spreadsheets with triple replicates. There always are a few labs that do not complete the full set of three replicates, and I do not want their data included in my analysis. First, I combine all the individual spreadsheets into one large Excel spreadsheet. The replicates are in three columns: rep1, rep2, and rep3. I sort on each individual rep column in Excel. Then I go to both the top and the bottom of the list. For example, I sort on rep1 and go to the top of the list to delete any rows where a value for rep1 was not recorded. Then I go to the bottom of the list and delete any rows where rep1 is text instead of a number, for example, 0.001. I should say that the labs are instructed that they must complete all three replicates, and they must not enter results as text. Next I repeat the process for rep2 and rep3. I'll do a little more work in Excel on the large, combined table with all the lab data. I calculate in Excel the mean, standard deviation, and coefficient of variation for each of the three reps. Finally, I filter all the data and delete duplicate rows. This is necessary as I sometimes accidentally copy the same spreadsheet two times from a lab into my large table. Finally, I save the cleaned up table in *.csv format that is easily read into R. I know that R can do all of these things, but if you are just learning how to use R it might be easier to do some initial work in Excel, or a similar spreadsheet, before running your data through R. I also use MS-Word's mail merge feature to generate my code. I'll get three or four pages of code doing what I want for a single analytical test, for example, calcium. Then I'll use the mail merge feature to generate hundreds of pages of code with the other analytical tests (nitrogen, phosphorus, potassium, etc.). I just copy and paste the large, merged Word document into R. R cranks away for 30 minutes and I end up with several large tables (and these get additional editing in Ecel) and hundreds of beautiful graphs that would take weeks to create in Excel. I was amazed that Word would work. I expected all of Word's special print control codes would mess things up. I just recently received a new laptop computer, and now I have an occassional problem with Word's pretty print quotes, but if you know about that problem, it is easy to fix. Jerry Floren Minnesota Department of Agriculture Matthew Dowle-3 wrote: As can data.table (i.e. do 'having' in one statement) : DT = data.table(DF) DT[,list(n=length(NAME),mean(SCORE)),by=NAME][n==3] NAME n V2 [1,] James 3 64.0 [2,] Tom 3 78.7 but data.table isn't restricted to SQL functions (such as avg), any R functions can be used, sometimes for their side effects (such as plotting) rather than just returning data. Further data.table has a thing called 'join inherited scoping'. Say we knew the specific groups, we can go directly to them (without even looking at the rest of the data in the table) in very short and convenient syntax, which also happens to run quickly on large data sets (but can be useful just for the syntax alone) : setkey(DT,NAME) DT[c(James,Tom),mean(SCORE),mult=all] NAME V1 [1,] James 64.0 [2,] Tom 78.7 Notice there is no group by or even a by in the above. It inherits the scope from the join because mult=all means that James matches to multiple rows, as does Tom, creating two groups. It does it by binary search to the beginning of each group, binary search to the end of the group, and runs the R expression inside the scope of that group. An example of join inherited scoping for the side effects only : pdf(out.pdf) DT[c(James,Tom),plot(SCORE),mult=all] NULL data table dev.off() # out.pdf now contains 2 plots which you couldn't do in SQL because SQL has no plotting (or any of R's other packages). It aims to do this quickly. Where 'quickly' means 1) shorter code is quicker to write, read, debug and maintain and also 2) quicker to compute, and its 1 that often dominates 2. Finally, consider the following two statements which are both equivalent : sqldf(select NAME, avg(SCORE) from DF group by NAME having count(*) = 3) NAME avg(SCORE) 1 James 64.0 2 Tom 78.7 DT[ J(DT[,length(NAME),by=NAME][V1==3,NAME]), mean(SCORE), mult=all] NAME avg(SCORE) 1 James 64.0 2 Tom 78.7 Now ok I hear you groaning (!) that the 2nd looks (on first glance) ugly, but bear with me ... in the SQL solution do you know for sure that avg(SCORE) isn't computed wastefully for the all the groups that don't have count(*)=3 ? It might well do the 'group by' first for all the groups, then do the 'having' afterwards as a 'where' on the result. It might depend on
Re: [R] Building static HTML help pages in R 2.10.x on Windows
On 07/01/2010 10:00 AM, Michal Kulich wrote: On 7.1.2010 15:52, Duncan Murdoch wrote: Not necessarily. The current help system can display information about the current session, e.g. the result of ls(), as a simple example. But if you use a single background session you won't get relevant information. Duncan Murdoch Sorry, I must admit I don't get it. A more useful example than ls() would be methods(). I think it would be nice to have a list of methods included in the man page for a generic function, and links to their pages if they have their own man pages. You might want to list all installed methods, with some sort of highlighting to indicate which ones are already attached, or perhaps be able to toggle between installed and attached, or whatever. None of that is possible with static help, not even a list of installed methods, because someone might install a new package that offers some others after the static help has already been built. You just need to use some imagination. 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] Identifying outliers in non-normally distributed data
Thank you Bert and Steve for your insights and suggestions. Bert, your suggestion to meet with a professional statician is right on. We have collected some great data since 2003, but I need professional help. I am sure some recommendations could be made to improve the laboratory methods based on the data collected. Thanks Steve for the link to, The International Harmonized Protocol for the Proficiency Testing of Analytical Chemistry Laboratories. I have found some great ideas in that publication. Thank you both, Jerry Floren Minnesota Department of Agriculture S Ellison wrote: If you're interested in handling outliers in analytical proficiency testing read current and past IUPAC guidance on PT (see http://www.iupac.org/objID/Article/pac7801x0145) and particularly references 1, 4, 5, and 11 therein, for starters. Although one might reasonably ask whether outliers are real or not, bitter experience says that the vast majority of them in PT are mistakes, so it is very widely accepted in teh PT community that if you;re going to use consensus values, you should use some form of robust estimate. In that context, outlier rejection is a crude robustification - but better methods exist and are recommended. If you're looking at data which have asymmetry for good reason, do something ordinary (like taking logs) to get the underlying distribution near-normal before using robust stats. If the asymmetry is just because of the outliers, maybe you have a more awkward problem. But even then, something like an MM-estimate or (since this is univariate) pretty much any robust estimate using a redescending influence function will help. Steve E Bert Gunter gunter.ber...@gene.com 12/30/09 7:09 PM Gents: Whole books could be -- and have been -- written on this matter. Personally, when scientists start asking me about criteria for outlier removal, it sends shivers up my spine and I break into a cold, clammy sweat. What is an outlier anyway? Statisticians (of which I'm one) have promulgated the deception that outliers can be defined by purely statistical criteria, and that they can then be removed from the analysis. That is a lie. The only acceptable scientific definition of an outlier that can be legitimately removed is of data that can be confirmed to have been corrupted in some way, for example, as Jerry describes below. All purely statistical criteria are arbitrary in some way and therefore potentially dangerous. The real question is: what is the scientific purpose of the analysis? -- how are the results to be used? There are a variety of effective so-called robust/resistant statistical procedures (e.g. see the R packages robust, robustbase, and rrcov, among many others) that might then be useful to accomplish the purpose even in the presence of unusual values (outliers is a term I now avoid due to its 'political' implications). This is almost always a wiser course of action (there are even theoretical justifications for this) than using statistical criteria to identify and remove the unusual values. However, use of such tools involves subtle issues that probably cannot be properly aired in a forum such as this. I therefore think you would do well to get a competent local statistician to consult with on these matters. Yes, I do believe that scientists often require advanced statistical tools that go beyond their usual training to properly analyze even what appear to be straightforward scientific data. It is a conundrum I cannot resolve, but that does not mean I can deny it. Finally, a word of wisdom from a long-ago engineering colleague: Whenever I see an outlier, I'm never sure whether to throw it away or patent it. Cheers, Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jerry Floren Sent: Wednesday, December 30, 2009 9:47 AM To: r-help@r-project.org Subject: Re: [R] Identifying outliers in non-normally distributed data Greetings: I could also use guidance on this topic. I provide manure sample proficiency sets to agricultural labs in the United States and Canada. There are about 65 labs in the program. My data sets are much smaller and typically non-symmetrical with obvious outliers. Usually, there are 30 to 60 sets of data, each with triple replicates (90 to 180 observations). There are definitely outliers caused by the following: reporting in the wrong units, sending in the wrong spreadsheet, entering data in the wrong row, misplacing decimal points, calculation errors, etc. For each analysis, it is common that two to three labs make these types of errors. Since there are replicates, errors like misplaced decimal points are more obvious. However, most of the outlier errors are repeated for all three replicates. I use the median and Median Absolute Deviation
[R] Patterns in histogram
I’ve been busy making some histograms and I would like to distinguish different groups. I’ve been doing it like this: a - c(1,1,1,1,2,2,2) hist(a,breaks=c(0,1,2)) hist(a[3:5],breaks=c(0,1,2),col=red,add=TRUE) Basically plotting them over each other, I assume there is a better way…Anyway what I want to do is make them in grayscale which essentially means giving different groups patterns. I’ve been playing around with “density” and “angle” a - c(1,1,1,1,2,2,2) hist(a,breaks=c(0,1,2)) hist(a[3:5],breaks=c(0,1,2),add=TRUE,,density=3,angle=9) Although you can make many different combinations with these I wondered if there are “patterns” (dots for example) available in the similar fashion as the colors (col=red or pattern=dots) cheers, Dennis -- View this message in context: http://n4.nabble.com/Patterns-in-histogram-tp1008928p1008928.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] Graph titles from massive
Dear all, I would like to ask you if there is a possibility in R to give the names to graphs which are not const. For example, How to name each plot, or to add notes like a=x[i], b=y[i] in this cycle x-c(1,2,3,4,5,6) y-c(7,8,9,10,11,12) par(mfrow=c(2,3)) for (i in 1:6){ plot(x,y) } Thank you for your time and help! [[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] Building static HTML help pages in R 2.10.x on Windows
For what it is worth, I would gladly sacrifice this capability in order to be able to consult all my R help pages through a Firefox bookmark to the packages listing (which is what I used to do, and will do again, when I get time to either rebuild from source or get the forthcoming Fedora RPM, which will have static pages as the default), without starting an R session. Jon On 01/07/10 10:32, Duncan Murdoch wrote: A more useful example than ls() would be methods(). I think it would be nice to have a list of methods included in the man page for a generic function, and links to their pages if they have their own man pages. You might want to list all installed methods, with some sort of highlighting to indicate which ones are already attached, or perhaps be able to toggle between installed and attached, or whatever. None of that is possible with static help, not even a list of installed methods, because someone might install a new package that offers some others after the static help has already been built. You just need to use some imagination. 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] Graph titles from massive
use the 'main' parameter: for (i in 1:6){ plot(x,y,main=paste(Plot:, i)) } On Thu, Jan 7, 2010 at 11:24 AM, Trafim Vanishek rdapam...@gmail.comwrote: Dear all, I would like to ask you if there is a possibility in R to give the names to graphs which are not const. For example, How to name each plot, or to add notes like a=x[i], b=y[i] in this cycle x-c(1,2,3,4,5,6) y-c(7,8,9,10,11,12) par(mfrow=c(2,3)) for (i in 1:6){ plot(x,y) } Thank you for your time and help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Patterns in histogram
On Jan 7, 2010, at 10:42 AM, dbeest wrote: I’ve been busy making some histograms and I would like to distinguish different groups. I’ve been doing it like this: a - c(1,1,1,1,2,2,2) hist(a,breaks=c(0,1,2)) hist(a[3:5],breaks=c(0,1,2),col=red,add=TRUE) Basically plotting them over each other, I assume there is a better way…Anyway what I want to do is make them in grayscale which essentially means giving different groups patterns. I’ve been playing around with “density” and “angle” a - c(1,1,1,1,2,2,2) hist(a,breaks=c(0,1,2)) hist(a[3:5],breaks=c(0,1,2),add=TRUE,,density=3,angle=9) Although you can make many different combinations with these I wondered if there are “patterns” (dots for example) available in the similar fashion as the colors (col=red or pattern=dots) I have not been able t find such. But you can also get the shading lines to respond to lty and to a very limited extent to lwd, ... at least I was not able to get arbitrarily thick lines on my screen graphics device (Quartz). The help pages I looked at suggested that different graphics devices might have varying parameters that could be fiddled with. -- David Winsemius, MD Heritage Laboratories 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] Graph titles from massive
On Jan 7, 2010, at 11:24 AM, Trafim Vanishek wrote: Dear all, I would like to ask you if there is a possibility in R to give the names to graphs which are not const. For example, How to name each plot, or to add notes like a=x[i], b=y[i] in this cycle x-c(1,2,3,4,5,6) y-c(7,8,9,10,11,12) par(mfrow=c(2,3)) for (i in 1:6){ plot(x,y) } This might be what you want: x-c(1,2,3,4,5,6) y-c(7,8,9,10,11,12) par(mfrow=c(2,3)) for (i in 1:6){ + plot(x,y, main=paste(this is plot # , i, sep=)) + } I initially thought you wanted the object names to be different for which this answer would not be responsive and no answer could be provided since that is not how base graphics work. For that you would need grid, lattice, or ggplot methods. David Winsemius, MD Heritage Laboratories 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] logistic regression based on principle component analysis
Dear all: I try to analyse a dataset which contain one binary response variable and serveral predict variables, but multiple colinear problem exists in my dataset, some paper suggest that logistic regression for principle components is suit for these noise data, but i only find R can done principle component regression using pls package, is there any package that can do the task i need - logistic regression based on principle components, if not, can anyone give some suggestion about how to use R to do my work. Thanks very much! best regards! wenkai _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] logistic regression based on principle component analysis
Hi, On Thu, Jan 7, 2010 at 11:57 AM, 江文恺 biology0...@hotmail.com wrote: Dear all: I try to analyse a dataset which contain one binary response variable and serveral predict variables, but multiple colinear problem exists in my dataset, some paper suggest that logistic regression for principle components is suit for these noise data, but i only find R can done principle component regression using pls package, is there any package that can do the task i need - logistic regression based on principle components, if not, can anyone give some suggestion about how to use R to do my work. Is this any different than first doing PCA to do the dimensionality reduction (which presumably will take care of your colinearity), then doing the logistic regression on your reduced input space? If so: no package is really necessary, right? It's just a two-step solution you need to write up. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Is nested namespace supported?
I don't find where in the R document the discussion of nested namespace is. If there is nested namespace supported in R, could somebody let me know whether the document is? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] faster GLS code
Dear helpers, I wrote a code which estimates a multi-equation model with generalized least squares (GLS). I can use GLS because I know the covariance matrix of the residuals a priori. However, it is a bit slow and I wonder if anybody would be able to point out a way to make it faster (it is part of a bigger code and needs to run several times). Any suggestion would be greatly appreciated. Carlo *** Carlo Fezzi Senior Research Associate Centre for Social and Economic Research on the Global Environment (CSERGE), School of Environmental Sciences, University of East Anglia, Norwich, NR4 7TJ United Kingdom. email: c.fe...@uea.ac.uk *** Here is an example with 3 equations and 2 exogenous variables: - start code -- N - 1000 # number of observations library(MASS) ## parameters ## # eq. 1 b10 - 7; b11 - 2; b12 - -1 # eq. 2 b20 - 5; b21 - -2; b22 - 1 # eq.3 b30 - 1; b31 - 5; b32 - 2 # exogenous variables x1 - runif(min=-10,max=10,N) x2 - runif(min=-5,max=5,N) # residual covariance matrix sigma - matrix(c(2,1,0.7,1,1.5,0.5,0.7,0.5,2),3,3) # residuals r - mvrnorm(N,mu=rep(0,3), Sigma=sigma) # endogenous variables y1 - b10 + b11 * x1 + b12*x2 + r[,1] y2 - b20 + b21 * x1 + b22*x2 + r[,2] y3 - b30 + b31 * x1 + b32*x2 + r[,3] y - cbind(y1,y2,y3)# matrix of endogenous x - cbind(1,x1, x2)# matrix of exogenous MODEL ESTIMATION ### # build the big X matrix needed for GLS estimation: X - kronecker(diag(1,3),x) Y - c(y) # stack the y in a vector # residual covariance matrix for each observation covar - kronecker(sigma,diag(1,N)) # GLS betas covariance matrix inv.sigma - solve(covar) betav - solve(t(X)%*%inv.sigma%*%X) # GLS mean parameter estimates betam - betav%*%t(X)%*%inv.sigma%*%Y - end of 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] Strange behaviour of as.integer()
Use round(), floor(), or ceiling() to convert numbers with possible fractional parts to numbers without fraction parts. as.integer()'s main use is to convert from one internal representation (i.e., bit pattern) of a number to another so you can interface to C or Fortran code. Note that as.integer(x) also doesn't work when abs(x)2^31, while round(), floor(), and ceiling() do work up to c. 2^52. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ulrich Keller Sent: Thursday, January 07, 2010 4:32 AM To: r-help@r-project.org Subject: [R] Strange behaviour of as.integer() I have encountered a strange behaviour of as.integer() which does not seem correct to me. Sorry if this is just an indication of me not understanding floating point arithmetic. .57 * 100 [1] 57 .29 * 100 [1] 29 So far, so good. But: as.integer(.57 * 100) [1] 56 as.integer(.29 * 100) [1] 28 Then again: all.equal(.57 * 100, as.integer(57)) [1] TRUE all.equal(.29 * 100, as.integer(29)) [1] TRUE This behaviour is the same in R 2.10.1 (Ubuntu and Windows) and 2.9.2 (Windows), all 32 bit versions. Is this really intended? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] factor graphics with pca in R?
Dear R users, I need to know whether the factor graphics with principal component analysis are implemented in R. I mean the graphs where the variables are represented in a correlation circle, as described in more detail in this document: http://www.unesco.org/webworld/idams/advguide/Chapt6_4_3.htm It is not a pain to program it myself, nevertheless it would be a waste of time if it is already implemented in R. Regards, 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.
Re: [R] logistic regression based on principle component analysis
for an alternative (lasso) approach, look at the packages (CRAN) grpreg, grplasso, glmnet, penalized and certainly some others. Kjetil B H On Thu, Jan 7, 2010 at 2:06 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi, On Thu, Jan 7, 2010 at 11:57 AM, 江文恺 biology0...@hotmail.com wrote: Dear all: I try to analyse a dataset which contain one binary response variable and serveral predict variables, but multiple colinear problem exists in my dataset, some paper suggest that logistic regression for principle components is suit for these noise data, but i only find R can done principle component regression using pls package, is there any package that can do the task i need - logistic regression based on principle components, if not, can anyone give some suggestion about how to use R to do my work. Is this any different than first doing PCA to do the dimensionality reduction (which presumably will take care of your colinearity), then doing the logistic regression on your reduced input space? If so: no package is really necessary, right? It's just a two-step solution you need to write up. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 on Reduce + rollmean
Dear Gabor Henrique, Thanks for your suggestions on the above problem. The following is more traditional and unfanciful but it works. Suitable for a prodige like myself... m - matrix(1:3,3,3) x1 - list(m, m+1, m+2, m+3, m+4) out - list() for (i in 1:4){ t[[i]] - Reduce(+, x1[c(i:i+1)]) } Muhammad Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk Gabor Grothendieck wrote: Here is a variation which also uses head and tail: mapply(function(x, y) (x + y)/2, tail(x, -1), head(x, -1), SIMPLIFY = FALSE) On Mon, Jan 4, 2010 at 12:37 PM, Henrique Dallazuanna www...@gmail.com wrote: For this example try this: lapply(lapply(list('head', 'tail'), do.call, list(x, n = -1)), function(x)Reduce('+', x)/2) On Mon, Jan 4, 2010 at 1:54 PM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk wrote: Thanks Gabor, It works alright. But is there alternative ways to perform rollmean apart from permutating the data? Possibly combining the Reduce and rollmean functions? The easiest but traditional way is (x[[1]]+x[[2]]) / 2 (x[[2]]+x[[3]]) / 2 Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk Gabor Grothendieck wrote: Try apply: library(zoo) # rollmean # test data m - matrix(1:3, 3, 3) x - list(m, m+3, m+6) # convert to array a - array(unlist(x), c(3, 3, 3)); a # apply rollmean and permute to desired form aa - apply(a, 1:2, rollmean, k = 2) aperm(aa, c(2, 3, 1)) The last line outputs: aperm(aa, c(2, 3, 1)) , , 1 [,1] [,2] [,3] [1,] 2.5 2.5 2.5 [2,] 3.5 3.5 3.5 [3,] 4.5 4.5 4.5 , , 2 [,1] [,2] [,3] [1,] 5.5 5.5 5.5 [2,] 6.5 6.5 6.5 [3,] 7.5 7.5 7.5 On Sat, Jan 2, 2010 at 10:00 AM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk wrote: Let me rephrase; Given x as x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 I'd like to calculate the moving average (interval = 2) i.e. ( x[[1]] + x[[2]] ) / 2 ( x[[2]] + x[[3]] ) / 2 ... and so on. The desired output will return 2.5 2.5 2.5 3.5 3.5 3.5 4.5 4.5 4.5 5.5 5.5 5.5 6.5 6.5 6.5 7.5 7.5 7.5 Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk milton ruser wrote: Dear M.Rahiz, Unfortunatelly I can't reproduce your example. PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html bests milton On Sat, Jan 2, 2010 at 9:26 AM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.ukmailto:muhammad.ra...@ouce.ox.ac.uk wrote: Hello useRs, I'd like to perform a moving average on the dataset, xx. I've tried combining the functions Reduce and rollmean but it didn't work. r - function(n) rollmean(n, 2) # where 2 = averaging interval output - Reduce(r, x) Error in f(init, x[[i]]) : unused argument(s) (x[[i]]) Is there anything wrong with the code in the first place? where x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 The moving average is to be performed on 1,4,7 = (1+4)/2 , (4+7)/2 2,5,8 = .. 3,6,9 = .. Thanks Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.ukmailto:muhammad.ra...@ouce.ox.ac.uk __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __
Re: [R] logistic regression based on principle component analysis
Frank Harrell, Jr shows you how to implement this in R, in his book, Regression Modeling Strategies. ~~~ Scott R Millis, PhD, ABPP (CN,CL,RP), CStat, CSci Professor Director of Research Dept of Physical Medicine Rehabilitation Dept of Emergency Medicine Wayne State University School of Medicine 261 Mack Blvd Detroit, MI 48201 Email: aa3...@wayne.edu Email: srmil...@yahoo.com Tel: 313-993-8085 Fax: 313-966-7682 --- On Thu, 1/7/10, Kjetil Halvorsen kjetilbrinchmannhalvor...@gmail.com wrote: From: Kjetil Halvorsen kjetilbrinchmannhalvor...@gmail.com Subject: Re: [R] logistic regression based on principle component analysis To: Steve Lianoglou mailinglist.honey...@gmail.com Cc: r-help@r-project.org, 江文恺 biology0...@hotmail.com Date: Thursday, January 7, 2010, 12:27 PM for an alternative (lasso) approach, look at the packages (CRAN) grpreg, grplasso, glmnet, penalized and certainly some others. Kjetil B H On Thu, Jan 7, 2010 at 2:06 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi, On Thu, Jan 7, 2010 at 11:57 AM, 江文恺 biology0...@hotmail.com wrote: Dear all: I try to analyse a dataset which contain one binary response variable and serveral predict variables, but multiple colinear problem exists in my dataset, some paper suggest that logistic regression for principle components is suit for these noise data, but i only find R can done principle component regression using pls package, is there any package that can do the task i need - logistic regression based on principle components, if not, can anyone give some suggestion about how to use R to do my work. Is this any different than first doing PCA to do the dimensionality reduction (which presumably will take care of your colinearity), then doing the logistic regression on your reduced input space? If so: no package is really necessary, right? It's just a two-step solution you need to write up. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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-pkgs] fortunes: 250th fortune
Hi, Thank you for this fun package. I recently posted a related question on R-help that seemed to pass unnoticed. Basically, I suggested that the functionality of fortunes could be extended to R FAQ entries, also allowing contributed packages to provide their own (fortune or) faq data file. My initial suggestion is here: http://markmail.org/message/oisbnuugifx5e36k I played with the fortune() source code and it doesn't take much effort to amend it for FAQ-like entries (I did not go as far as converting all the official FAQ entries, that's another problem). However such an approach is suboptimal in that most of the code would be duplicated. Would it make sense to write a slightly more general code working for a wider range of database entries? Best regards, baptiste 2010/1/6 Achim Zeileis achim.zeil...@wu-wien.ac.at: Dear useRs, it's a new year and time for a new CRAN-version of the fortunes package. Version 1.3-7 is now online at http://CRAN.R-project.org/package=fortunes which contains the 250th fortune: R fortune(250) As Obi-Wan Kenobi may have said in Star Wars: Use the source, Luke! -- Barry Rowlingson (answering a question on the documentation of some implementation details) R-devel (January 2010) Actually there is also the 251st... Thanks to all that have contributed to the fortunes package in the form of creating these nice quote or submitting them to the package. Best wishes, Z ___ 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building static HTML help pages in R 2.10.x on Windows
On 07/01/2010 11:36 AM, Jonathan Baron wrote: For what it is worth, I would gladly sacrifice this capability in order to be able to consult all my R help pages through a Firefox bookmark to the packages listing (which is what I used to do, and will do again, when I get time to either rebuild from source or get the forthcoming Fedora RPM, which will have static pages as the default), without starting an R session. What's so hard about leaving an R session running, and using bookmarks as Dieter described? Duncan Murdoch Jon On 01/07/10 10:32, Duncan Murdoch wrote: A more useful example than ls() would be methods(). I think it would be nice to have a list of methods included in the man page for a generic function, and links to their pages if they have their own man pages. You might want to list all installed methods, with some sort of highlighting to indicate which ones are already attached, or perhaps be able to toggle between installed and attached, or whatever. None of that is possible with static help, not even a list of installed methods, because someone might install a new package that offers some others after the static help has already been built. You just need to use some imagination. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Drop a part of an array\list\vector?
I did have a verbose description of why but rather then make everyone's eyes bleed with useless details I ask the following :) To make a long story short: How can I make newmcReg[[i]][PreIO308] go away in the following list... er vector... no wait array dataframe awww crap... summary(newmcReg[[i]]) UNITBUILD UNITDB ITBUILD ITDB Mode :logical Mode :logical Mode :logical Mode :logical FALSE:249 FALSE:249 FALSE:249 FALSE:249 TRUE :21TRUE :21TRUE :21TRUE :21 UATBUILD UATDB HOGANCODE ACF Mode :logical Mode :logical Mode :logical Mode :logical FALSE:250 FALSE:250 FALSE:208 FALSE:225 TRUE :20TRUE :20TRUE :62TRUE :45 RCF ReleaseST1 ReleaseST2 ReleaseBLA Mode :logical Mode :logical Mode :logical Mode :logical FALSE:186 FALSE:167 FALSE:157 FALSE:228 TRUE :84TRUE :103 TRUE :113 TRUE :42 MonthlyST1 MonthlyST2 MonthlyBLA Small.Bank.Acquisitions Mode :logical Mode :logical Mode :logical Min. :0. FALSE:107 FALSE:105 FALSE:147 1st Qu.:0. TRUE :163 TRUE :165 TRUE :123 Median :0. Mean :0.1556 3rd Qu.:0. Max. :1. Conversions Build.New.Environment HLY.NewYear HLY.MLK Min. :0.0 Mode :logical Mode :logical Mode :logical 1st Qu.:0.0 FALSE:262 FALSE:266 FALSE:264 Median :0.0 TRUE :8 TRUE :4 TRUE :6 Mean :0.08889 3rd Qu.:0.0 Max. :1.0 HLY.PRES HLY.MEMORIAL HLY.J4HLY.LABOR Mode :logical Mode :logical Mode :logical Mode :logical FALSE:264 FALSE:265 FALSE:265 FALSE:265 TRUE :6 TRUE :5 TRUE :5 TRUE :5 HLY.COLUMBUS HLY.VETS HLY.THANKS HLY.XMAS Mode :logical Mode :logical Mode :logical Mode :logical FALSE:265 FALSE:265 FALSE:265 FALSE:265 TRUE :5 TRUE :5 TRUE :5 TRUE :5 HLY.ELECT HLY.PATRIOTEOMNEWMF Mode :logical Mode :logical Mode :logical Mode :logical FALSE:265 FALSE:265 FALSE:210 FALSE:263 TRUE :5 TRUE :5 TRUE :60TRUE :7 PreIO47 PreIO151PreIO164PreIO169 Mode :logical Mode :logical Mode :logical Mode :logical FALSE:269 FALSE:269 FALSE:269 FALSE:269 TRUE :1 TRUE :1 TRUE :1 TRUE :1 PreIO197PreIO203PreIO209PreIO241 Mode :logical Mode :logical Mode :logical Mode :logical FALSE:269 FALSE:269 FALSE:269 FALSE:269 TRUE :1 TRUE :1 TRUE :1 TRUE :1 PreIO261PreIO308 Mode :logical Mode :logical FALSE:269 FALSE:270 TRUE :1 (the PreIO are outliers identified from the output of stl() e.g. outliers in the source data) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on Reduce + rollmean
That gives an error when I run it. I think you want this: m - matrix(1:3,3,3) x1 - list(m, m+1, m+2, m+3, m+4) out - list() for(i in 1:4) out[[i]] - (x1[[i]] + x1[[i+1]]) / 2 On Thu, Jan 7, 2010 at 12:28 PM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk wrote: Dear Gabor Henrique, Thanks for your suggestions on the above problem. The following is more traditional and unfanciful but it works. Suitable for a prodige like myself... m - matrix(1:3,3,3) x1 - list(m, m+1, m+2, m+3, m+4) out - list() for (i in 1:4){ t[[i]] - Reduce(+, x1[c(i:i+1)]) } Muhammad Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk Gabor Grothendieck wrote: Here is a variation which also uses head and tail: mapply(function(x, y) (x + y)/2, tail(x, -1), head(x, -1), SIMPLIFY = FALSE) On Mon, Jan 4, 2010 at 12:37 PM, Henrique Dallazuanna www...@gmail.com wrote: For this example try this: lapply(lapply(list('head', 'tail'), do.call, list(x, n = -1)), function(x)Reduce('+', x)/2) On Mon, Jan 4, 2010 at 1:54 PM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk wrote: Thanks Gabor, It works alright. But is there alternative ways to perform rollmean apart from permutating the data? Possibly combining the Reduce and rollmean functions? The easiest but traditional way is (x[[1]]+x[[2]]) / 2 (x[[2]]+x[[3]]) / 2 Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk Gabor Grothendieck wrote: Try apply: library(zoo) # rollmean # test data m - matrix(1:3, 3, 3) x - list(m, m+3, m+6) # convert to array a - array(unlist(x), c(3, 3, 3)); a # apply rollmean and permute to desired form aa - apply(a, 1:2, rollmean, k = 2) aperm(aa, c(2, 3, 1)) The last line outputs: aperm(aa, c(2, 3, 1)) , , 1 [,1] [,2] [,3] [1,] 2.5 2.5 2.5 [2,] 3.5 3.5 3.5 [3,] 4.5 4.5 4.5 , , 2 [,1] [,2] [,3] [1,] 5.5 5.5 5.5 [2,] 6.5 6.5 6.5 [3,] 7.5 7.5 7.5 On Sat, Jan 2, 2010 at 10:00 AM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk wrote: Let me rephrase; Given x as x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 I'd like to calculate the moving average (interval = 2) i.e. ( x[[1]] + x[[2]] ) / 2 ( x[[2]] + x[[3]] ) / 2 ... and so on. The desired output will return 2.5 2.5 2.5 3.5 3.5 3.5 4.5 4.5 4.5 5.5 5.5 5.5 6.5 6.5 6.5 7.5 7.5 7.5 Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk milton ruser wrote: Dear M.Rahiz, Unfortunatelly I can't reproduce your example. PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html bests milton On Sat, Jan 2, 2010 at 9:26 AM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.ukmailto:muhammad.ra...@ouce.ox.ac.uk wrote: Hello useRs, I'd like to perform a moving average on the dataset, xx. I've tried combining the functions Reduce and rollmean but it didn't work. r - function(n) rollmean(n, 2) # where 2 = averaging interval output - Reduce(r, x) Error in f(init, x[[i]]) : unused argument(s) (x[[i]]) Is there anything wrong with the code in the first place? where x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 The moving average is to be performed on 1,4,7 = (1+4)/2 , (4+7)/2 2,5,8 = .. 3,6,9 = .. Thanks Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.ukmailto:muhammad.ra...@ouce.ox.ac.uk __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting
[R] Return values in fExtremes package
Hi, I was usuing the fExtemes package, and wanted to obtain some of the values returned from the function gumbelFit(). For example, in the following code, I would like to access 'mu' and 'beta' from the object 'para'. How should I go about doing this? Is there any generic method to access the object? --- library(fExtremes) ss - gumbelSim(model = list(mu = 0, beta = 1), n = 1000, seed = NULL) para - gumbelFit(ss) print(para) Title: Gumbel Parameter Estimation Call: gumbelFit(x = ss) Estimation Type: gum mle Estimated Parameters: mubeta 0.005449572 1.010874131 Description Thu Jan 07 13:14:28 2010 class(para) [1] fGEVFIT attr(,package) [1] fExtremes --- thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on Reduce + rollmean
Yes, should be 1. out[[i]], instead of t[[i]]. 2. x1[c(i:(i+1))] # For this case, I was trying out the rolling sum. Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk Gabor Grothendieck wrote: That gives an error when I run it. I think you want this: m - matrix(1:3,3,3) x1 - list(m, m+1, m+2, m+3, m+4) out - list() for(i in 1:4) out[[i]] - (x1[[i]] + x1[[i+1]]) / 2 On Thu, Jan 7, 2010 at 12:28 PM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk wrote: Dear Gabor Henrique, Thanks for your suggestions on the above problem. The following is more traditional and unfanciful but it works. Suitable for a prodige like myself... m - matrix(1:3,3,3) x1 - list(m, m+1, m+2, m+3, m+4) out - list() for (i in 1:4){ t[[i]] - Reduce(+, x1[c(i:i+1)]) } Muhammad Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk Gabor Grothendieck wrote: Here is a variation which also uses head and tail: mapply(function(x, y) (x + y)/2, tail(x, -1), head(x, -1), SIMPLIFY = FALSE) On Mon, Jan 4, 2010 at 12:37 PM, Henrique Dallazuanna www...@gmail.com wrote: For this example try this: lapply(lapply(list('head', 'tail'), do.call, list(x, n = -1)), function(x)Reduce('+', x)/2) On Mon, Jan 4, 2010 at 1:54 PM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk wrote: Thanks Gabor, It works alright. But is there alternative ways to perform rollmean apart from permutating the data? Possibly combining the Reduce and rollmean functions? The easiest but traditional way is (x[[1]]+x[[2]]) / 2 (x[[2]]+x[[3]]) / 2 Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk Gabor Grothendieck wrote: Try apply: library(zoo) # rollmean # test data m - matrix(1:3, 3, 3) x - list(m, m+3, m+6) # convert to array a - array(unlist(x), c(3, 3, 3)); a # apply rollmean and permute to desired form aa - apply(a, 1:2, rollmean, k = 2) aperm(aa, c(2, 3, 1)) The last line outputs: aperm(aa, c(2, 3, 1)) , , 1 [,1] [,2] [,3] [1,] 2.5 2.5 2.5 [2,] 3.5 3.5 3.5 [3,] 4.5 4.5 4.5 , , 2 [,1] [,2] [,3] [1,] 5.5 5.5 5.5 [2,] 6.5 6.5 6.5 [3,] 7.5 7.5 7.5 On Sat, Jan 2, 2010 at 10:00 AM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk wrote: Let me rephrase; Given x as x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 I'd like to calculate the moving average (interval = 2) i.e. ( x[[1]] + x[[2]] ) / 2 ( x[[2]] + x[[3]] ) / 2 ... and so on. The desired output will return 2.5 2.5 2.5 3.5 3.5 3.5 4.5 4.5 4.5 5.5 5.5 5.5 6.5 6.5 6.5 7.5 7.5 7.5 Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk milton ruser wrote: Dear M.Rahiz, Unfortunatelly I can't reproduce your example. PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html bests milton On Sat, Jan 2, 2010 at 9:26 AM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.ukmailto:muhammad.ra...@ouce.ox.ac.uk wrote: Hello useRs, I'd like to perform a moving average on the dataset, xx. I've tried combining the functions Reduce and rollmean but it didn't work. r - function(n) rollmean(n, 2) # where 2 = averaging interval output - Reduce(r, x) Error in f(init, x[[i]]) : unused argument(s) (x[[i]]) Is there anything wrong with the code in the first place? where x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 The moving average is to be performed on 1,4,7 = (1+4)/2 , (4+7)/2 2,5,8 = .. 3,6,9 = ..
Re: [R] Calling FING.EXE under RGui.EXE for windows.
Argh. I see it as well. Will dig a lit tomorrow. Uwe On 07.01.2010 12:25, Gabor Grothendieck wrote: I get a problem with shell too: Under Rgui: R.version.string [1] R version 2.10.1 Patched (2010-01-01 r50884) system(C:\\windows\\system32\\find /?, intern = TRUE) character(0) system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE) character(0) shell(C:\\windows\\system32\\find /?) Warning message: In shell(C:\\windows\\system32\\find /?) : 'C:\windows\system32\find /?' execution failed with error code 1 They all work, i.e. they give the required help message, under Rterm and when I issue this from the Windows console it works: C:\windows\system32\find /? 2010/1/7 Uwe Liggeslig...@statistik.tu-dortmund.de: On 07.01.2010 02:04, Gabor Grothendieck wrote: If you have C:\Rtools\bin on your PATH note that it contains a UNIX-like find utility that conflicts with the find utility in Windows. If that is the problem then remove that from your PATH and then run the batch file. The batchfiles distribution at http://batchfiles.googlecode.com has utilities (Rgui.bat, R.bat, Rtools.bat, etc.) that will automatically add C:\Rtools\bin to your path temporarily or only while R is running so that you can leave it off your PATH. I guess it's the use of system() rather than shell() that causes the problem. Under Windows, you have to use shell in order to start a command interpreter. Uwe Ligges On Wed, Jan 6, 2010 at 6:51 PM, John Schexnayderjsc...@us.ibm.com wrote: This is sort of a strange bug. Not show stopping, but annoying. I was wondering if anyone else has noticed this and reported it before I submit a bug report. I noticed while running the RGui and attempting to debug one of my scripts that I encountered a Windows error informing me that Find String [grep] Utility has encountered a problem and needs to close. It is being generated by a call to a DOS batch file which contains a call to Find.exe. It can be reproduced by simply typing System(find) in RGui. What I found strange is that I have been running this script daily without this problem for months. I now realize I never ran that portion of the script while in RGui.exe. It has always run in batch mode which is done by Rterm.exe. I have tried this on three separate machines now all running Windows XP SP3, with versions of R 2.8.1 and R 2.10.1 If executing System(find) under RGui, an error window for the Find String Utility is generated and the command is not exectuted. If the same command is issued in Rterm the expected FIND: Parameter format not correct message is properly returned. It doesn't seem an important bug, but it could be the canary in the mine for a larger problem somewhere down the road. Re, John Schexnayder IBM Tape Manufacturing - Information Technology San Jose, CA 95138 jsc...@us.ibm.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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] factor graphics with pca in R?
Take a look at the FactoMineR and vegan packages. They may contain what you are looking for. Greg On 1/7/10 9:26 AM, Martin Ivanov wrote: Dear R users, I need to know whether the factor graphics with principal component analysis are implemented in R. I mean the graphs where the variables are represented in a correlation circle, as described in more detail in this document: http://www.unesco.org/webworld/idams/advguide/Chapt6_4_3.htm It is not a pain to program it myself, nevertheless it would be a waste of time if it is already implemented in R. Regards, 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. -- Greg Hirson ghir...@ucdavis.edu Graduate Student Agricultural and Environmental Chemistry 1106 Robert Mondavi Institute North One Shields Avenue Davis, CA 95616 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 report or correct translations typos?
Dear Duncan, Thank you for clarifying this issue. Cheers, Pablo - Original Message - From: Duncan Murdoch murd...@stats.uwo.ca To: Kenneth Roy Cabrera Torres krcab...@une.net.co Cc: r-help@r-project.org; pabloemilio.ve...@uni-duesseldorf.de Sent: Thursday, January 07, 2010 3:12 PM Subject: Re: [R] How to report or correct translations typos? On 07/01/2010 9:04 AM, Kenneth Roy Cabrera Torres wrote: Hi R users and developers: Thanks to Mr Pablo Emilio Verde for his constribution to the spanish translation for R messages he makes a very good job. I find a tiny typo on the translation, in particular on the es.po file line 7312 it says: pueto it should be: puerto How can anybody might correct a typo or which is the best way to correct it on a future patch? You can see the translation teams listed on http://developer.r-project.org/TranslationTeams.html. You send your corrections to them (as you have already done; this message is just to confirm you've done what you should do). Duncan Murdoch Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to read script name in littler
Hello, I am using littler to run my R code and I was looking for a way to read the running script name, but neither argv nor commandArgs() give me this information. Any suggestion? Thanks in advance. F. Pollastri __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Simple averaging question
I have the following data: http://i.imagehost.org/0650/Untitled2.jpg How would i average, say the 5th and the 8th entries? Thanks in advance -- View this message in context: http://n4.nabble.com/Simple-averaging-question-tp1009086p1009086.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] mean for subset
Did you really say you're using Word's mail merge to construct hundreds of pages of R code which you then paste in to R ? It sounds like you just missed somehow how to create a function in R. Did you fully read the book Introduction to R ? Did you know R can read xls directly, and connect to spreadsheets as if they were databases, see ?odbcConnectExcel. Your graphs may exist and be beautiful but are they correct ? This link contains a formal discussion of the topic : http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html Jerry Floren jerry.flo...@state.mn.us wrote in message news:1262877373634-1008892.p...@n4.nabble.com... As a novice R user, I face a similar challenge. I am almost afraid to share with this group how I solved it. About 65 labs in our proficiency program submit data on individual Excel spreadsheets with triple replicates. There always are a few labs that do not complete the full set of three replicates, and I do not want their data included in my analysis. First, I combine all the individual spreadsheets into one large Excel spreadsheet. The replicates are in three columns: rep1, rep2, and rep3. I sort on each individual rep column in Excel. Then I go to both the top and the bottom of the list. For example, I sort on rep1 and go to the top of the list to delete any rows where a value for rep1 was not recorded. Then I go to the bottom of the list and delete any rows where rep1 is text instead of a number, for example, 0.001. I should say that the labs are instructed that they must complete all three replicates, and they must not enter results as text. Next I repeat the process for rep2 and rep3. I'll do a little more work in Excel on the large, combined table with all the lab data. I calculate in Excel the mean, standard deviation, and coefficient of variation for each of the three reps. Finally, I filter all the data and delete duplicate rows. This is necessary as I sometimes accidentally copy the same spreadsheet two times from a lab into my large table. Finally, I save the cleaned up table in *.csv format that is easily read into R. I know that R can do all of these things, but if you are just learning how to use R it might be easier to do some initial work in Excel, or a similar spreadsheet, before running your data through R. I also use MS-Word's mail merge feature to generate my code. I'll get three or four pages of code doing what I want for a single analytical test, for example, calcium. Then I'll use the mail merge feature to generate hundreds of pages of code with the other analytical tests (nitrogen, phosphorus, potassium, etc.). I just copy and paste the large, merged Word document into R. R cranks away for 30 minutes and I end up with several large tables (and these get additional editing in Ecel) and hundreds of beautiful graphs that would take weeks to create in Excel. I was amazed that Word would work. I expected all of Word's special print control codes would mess things up. I just recently received a new laptop computer, and now I have an occassional problem with Word's pretty print quotes, but if you know about that problem, it is easy to fix. Jerry Floren Minnesota Department of Agriculture Matthew Dowle-3 wrote: As can data.table (i.e. do 'having' in one statement) : DT = data.table(DF) DT[,list(n=length(NAME),mean(SCORE)),by=NAME][n==3] NAME n V2 [1,] James 3 64.0 [2,] Tom 3 78.7 but data.table isn't restricted to SQL functions (such as avg), any R functions can be used, sometimes for their side effects (such as plotting) rather than just returning data. Further data.table has a thing called 'join inherited scoping'. Say we knew the specific groups, we can go directly to them (without even looking at the rest of the data in the table) in very short and convenient syntax, which also happens to run quickly on large data sets (but can be useful just for the syntax alone) : setkey(DT,NAME) DT[c(James,Tom),mean(SCORE),mult=all] NAME V1 [1,] James 64.0 [2,] Tom 78.7 Notice there is no group by or even a by in the above. It inherits the scope from the join because mult=all means that James matches to multiple rows, as does Tom, creating two groups. It does it by binary search to the beginning of each group, binary search to the end of the group, and runs the R expression inside the scope of that group. An example of join inherited scoping for the side effects only : pdf(out.pdf) DT[c(James,Tom),plot(SCORE),mult=all] NULL data table dev.off() # out.pdf now contains 2 plots which you couldn't do in SQL because SQL has no plotting (or any of R's other packages). It aims to do this quickly. Where 'quickly' means 1) shorter code is quicker to write, read, debug and maintain and also 2) quicker to compute, and its 1 that often dominates 2. Finally, consider the following two
Re: [R] Simple averaging question
Assuming the data frame is named X: mean(X[c(5,8), Time]) See ?'[' for details. -Ista On Thu, Jan 7, 2010 at 1:20 PM, lse1986 sam_eden1...@yahoo.co.uk wrote: I have the following data: http://i.imagehost.org/0650/Untitled2.jpg How would i average, say the 5th and the 8th entries? Thanks in advance -- View this message in context: http://n4.nabble.com/Simple-averaging-question-tp1009086p1009086.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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with writeBin and importing into gfortran compiled programs
Hi all, I'm having problems trying to export binary arrays from R and importing them into fortran (linux openSUSE 10.3 (x86_64), gfortran compiler, fortran 90/95 program). Let's say the problem can be expressed as: R part whini - runif(1000) writeBin(whini,fwhini.dat) f90 part PROGRAM foo INTEGER, PARAMETER :: DP = KIND(1.0D0) INTEGER :: status REAL(DP), DIMENSION(10,100) :: whini OPEN(UNIT=5, FILE='fwhini.dat', STATUS='OLD', ACTION='READ', FORM='UNFORMATTED', IOSTAT=status) READ(5) whini CLOSE(5) WRITE(*,*) whini END PROGRAM Now, if within the R session I check typeof(whini) [1] double and try whini.copy - readBin(fwhini.dat,what=double(),n=1000) the copy of whini is right. However, execution of the fortran program gives the message: Fortran runtime error: Unformatted file structure has been corrupted. I've tried also to declare whini in the fortran part as SINGLE precision, and to force writeBin using the size argument. size=4 and size=8 give the same error (whini as double in the fortran part), while size=16 gives the alternative error Fortran runtime error: I/O past end of record on unformatted file Please, could you help me with this problem? Thanks, Javier --- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generating data from Null Distribution
Just randomly permute one of your columns (see ?sample) of the raw data (before using the table function to get the table). -- 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 Jim Silverton Sent: Wednesday, January 06, 2010 1:17 AM To: r-help@r-project.org Subject: Re: [R] Generating data from Null Distribution Hello everyone, Can someone tell me exactly how to generate data from a null distribution for the fisher exact test? I know I have to use the hypergrometric but exactly what commands do I use? Jim [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] faster GLS code
Try this: X - kronecker(diag(1,3),x) Y - c(y) # stack the y in a vector # residual covariance matrix for each observation covar - kronecker(sigma,diag(1,N)) csig - chol2inv(covar) betam2 - ginv(csig %*% X) %*% csig %*% Y This is more than 2 times faster than your code (however, it doesn't compute `betav') . Here is a timing comparison: # Your method # GLS betas covariance matrix system.time({ inv.sigma - solve(covar) betav - solve(t(X)%*%inv.sigma%*%X) # GLS mean parameter estimates betam - betav%*%t(X)%*%inv.sigma%*%Y }) # New method system.time({ csig - chol2inv(covar) betam2 - ginv(csig %*% X) %*% csig %*% Y }) all.equal(betam, betam2) # GLS betas covariance matrix system.time({ + inv.sigma - solve(covar) + betav - solve(t(X)%*%inv.sigma%*%X) + + # GLS mean parameter estimates + betam - betav%*%t(X)%*%inv.sigma%*%Y + }) user system elapsed 1.140.511.76 system.time({ + csig - chol2inv(covar) + betam2 - ginv(csig %*% X) %*% csig %*% Y + }) user system elapsed 0.470.080.61 all.equal(betam, betam2) [1] TRUE Hope this helps, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Carlo Fezzi c.fe...@uea.ac.uk Date: Thursday, January 7, 2010 12:13 pm Subject: [R] faster GLS code To: r-help@r-project.org Dear helpers, I wrote a code which estimates a multi-equation model with generalized least squares (GLS). I can use GLS because I know the covariance matrix of the residuals a priori. However, it is a bit slow and I wonder if anybody would be able to point out a way to make it faster (it is part of a bigger code and needs to run several times). Any suggestion would be greatly appreciated. Carlo *** Carlo Fezzi Senior Research Associate Centre for Social and Economic Research on the Global Environment (CSERGE), School of Environmental Sciences, University of East Anglia, Norwich, NR4 7TJ United Kingdom. email: c.fe...@uea.ac.uk *** Here is an example with 3 equations and 2 exogenous variables: - start code -- N - 1000# number of observations library(MASS) ## parameters ## # eq. 1 b10 - 7; b11 - 2; b12 - -1 # eq. 2 b20 - 5; b21 - -2; b22 - 1 # eq.3 b30 - 1; b31 - 5; b32 - 2 # exogenous variables x1 - runif(min=-10,max=10,N) x2 - runif(min=-5,max=5,N) # residual covariance matrix sigma - matrix(c(2,1,0.7,1,1.5,0.5,0.7,0.5,2),3,3) # residuals r - mvrnorm(N,mu=rep(0,3), Sigma=sigma) # endogenous variables y1 - b10 + b11 * x1 + b12*x2 + r[,1] y2 - b20 + b21 * x1 + b22*x2 + r[,2] y3 - b30 + b31 * x1 + b32*x2 + r[,3] y - cbind(y1,y2,y3) # matrix of endogenous x - cbind(1,x1, x2) # matrix of exogenous MODEL ESTIMATION ### # build the big X matrix needed for GLS estimation: X - kronecker(diag(1,3),x) Y - c(y) # stack the y in a vector # residual covariance matrix for each observation covar - kronecker(sigma,diag(1,N)) # GLS betas covariance matrix inv.sigma - solve(covar) betav - solve(t(X)%*%inv.sigma%*%X) # GLS mean parameter estimates betam - betav%*%t(X)%*%inv.sigma%*%Y - end of code __ R-help@r-project.org mailing list PLEASE do read the posting guide 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] Building static HTML help pages in R 2.10.x on Windows
Well, among other things, if my global environment becomes cluttered/corrupt/etc and I quit R, then restart R, the links in my browser are now dead. I have to close all the tabs and call help to open them again. Also, the R-supplied java tool for searching help is ancient and underwhelming. A desktop search tool (X1/Copernic/GoogleDesktop/etc) can be very handy, but only if it has pre-built help files to index. Imperfect, stale, non-dynamic help is better than no help at all! As others have done, I have switched back to 2.9.2 until I can build all help files (on Windows). Thanks to those people who are figuring out how to do this. Kevin On Thu, Jan 7, 2010 at 11:50 AM, Duncan Murdoch murd...@stats.uwo.cawrote: On 07/01/2010 11:36 AM, Jonathan Baron wrote: For what it is worth, I would gladly sacrifice this capability in order to be able to consult all my R help pages through a Firefox bookmark to the packages listing (which is what I used to do, and will do again, when I get time to either rebuild from source or get the forthcoming Fedora RPM, which will have static pages as the default), without starting an R session. What's so hard about leaving an R session running, and using bookmarks as Dieter described? Duncan Murdoch Jon On 01/07/10 10:32, Duncan Murdoch wrote: A more useful example than ls() would be methods(). I think it would be nice to have a list of methods included in the man page for a generic function, and links to their pages if they have their own man pages. You might want to list all installed methods, with some sort of highlighting to indicate which ones are already attached, or perhaps be able to toggle between installed and attached, or whatever. None of that is possible with static help, not even a list of installed methods, because someone might install a new package that offers some others after the static help has already been built. You just need to use some imagination. 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. -- Kevin Wright [[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 formating data to display commas
I'm using the following code to create quartile intervals of my dataset and it is working like it is suppose too. In my final output of the data I would like currency amounts to be displayed with commas. I have not found an option either through FormatC or sprintf that will display the data with commas, they only seem to add decimals. Is there a format that will display commas without me reverting to the labels statement. This is an ongoing process where the values are updated, so using the labels statement would be too much to manage. Benchparaq-levels(quantcut(benchmarkPara$Benchmark_Total, q=seq(0,1,by=0.25), na.rm=TRUE)) #,labels=c($267,000-$436,000,$436,000-$559,000,$559,000-$836,000,$836,000-$1,590,000)) lower -as.numeric(sub(\\((.+),.*, \\1, Benchparaq)) Warning: NAs introduced by coercion upper - as.numeric(sub([^,]*,([^]]*)\\], \\1, Benchparaq)) lower-ifelse(is.na(lower),0,as.numeric(lower)) upper-ifelse(is.na(upper),0,as.numeric(upper)) lower [1] 0 436000 559000 836000 upper [1] 436000 559000 836000 159 Benchparaq-paste($,lower,-,$,upper,sep=) lower-NULL upper-NULL Benchparaq [1] $0-$436000 $436000-$559000 $559000-$836000 $836000-$159 Chris Anderson Data Analyst Medical Affairs wk: 925-677-4870 cell: 707-315-8486 Fax:925-677-4670 This electronic message transmission, including any attachments, contains information which may be confidential, privileged and/or otherwise exempt from disclosure under applicable law. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this information is strictly prohibited. If you have received this electronic transmission in error, please notify the sender immediately by telephone (800-676-6777) or by a reply to sender only message and destroy all electronic and hard copies of the communication, including attachments. Thank you. For more information on Paradigm Management Services, LLC, please visit http://www.paradigmcorp.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] %d/%m/%Y can not be displayed in a .rd file
Hi all, I found the date format (e.g.%d/%m/%Y) in the .rd file cannot be displayed after building the package. See below, ###.rd file \examples{ a-10/20/1999 DateConversion(a,DateIn=%m/%d/%Y,DateOut=%d/%m/%Y) } The result is Examples: a-10-20-1999 DateConversion(a,DateIn= ??%m/%d/%Y seems cannot be recognized. Is there some method to solve this and make it visible? Thanks a lot. -- - Jane Chang Queen'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] Drop a part of an array\list\vector?
On Jan 7, 2010, at 1:15 PM, Idgarad wrote: I did have a verbose description of why but rather then make everyone's eyes bleed with useless details I ask the following :) To make a long story short: How can I make newmcReg[[i]][PreIO308] go away in the following list... er vector... no wait array dataframe awww crap... The data type returned by summary appears to be a table, ... which means it can be indexed as would be a matrix: summary(data.frame( a= c(TRUE, FALSE, TRUE), b= c(TRUE,TRUE,TRUE), cc =c(a, b , c) )) a b cc Mode :logical Mode:logical a:1 FALSE:1 TRUE:3 b:1 TRUE :2 NA's:0 c:1 NA's :0 str(summary(data.frame( a= c(TRUE, FALSE, TRUE), b= c(TRUE,TRUE,TRUE), cc =c(a, b , c) ))) 'table' chr [1:4, 1:3] Mode :logical FALSE:1 TRUE : 2 NA's :0 ... - attr(*, dimnames)=List of 2 ..$ : chr [1:4] ..$ : chr [1:3] ab cc summary(data.frame( a= c(TRUE, FALSE, TRUE), b= c(TRUE,TRUE,TRUE), cc =c(a, b , c) ))[, 1:2] ab Mode :logical Mode:logical FALSE:1 TRUE:3 TRUE :2 NA's:0 NA's :0 NA Although there appear to be some underlying print-issues. -- David summary(newmcReg[[i]]) UNITBUILD UNITDB ITBUILD ITDB Mode :logical Mode :logical Mode :logical Mode :logical FALSE:249 FALSE:249 FALSE:249 FALSE:249 TRUE :21TRUE :21TRUE :21TRUE :21 UATBUILD UATDB HOGANCODE ACF Mode :logical Mode :logical Mode :logical Mode :logical FALSE:250 FALSE:250 FALSE:208 FALSE:225 TRUE :20TRUE :20TRUE :62TRUE :45 RCF ReleaseST1 ReleaseST2 ReleaseBLA Mode :logical Mode :logical Mode :logical Mode :logical FALSE:186 FALSE:167 FALSE:157 FALSE:228 TRUE :84TRUE :103 TRUE :113 TRUE :42 MonthlyST1 MonthlyST2 MonthlyBLA Small.Bank.Acquisitions Mode :logical Mode :logical Mode :logical Min. :0. FALSE:107 FALSE:105 FALSE:147 1st Qu.:0. TRUE :163 TRUE :165 TRUE :123 Median :0. Mean :0.1556 3rd Qu.:0. Max. :1. Conversions Build.New.Environment HLY.NewYear HLY.MLK Min. :0.0 Mode :logical Mode :logical Mode :logical 1st Qu.:0.0 FALSE:262 FALSE:266 FALSE:264 Median :0.0 TRUE :8 TRUE :4 TRUE :6 Mean :0.08889 3rd Qu.:0.0 Max. :1.0 HLY.PRES HLY.MEMORIAL HLY.J4HLY.LABOR Mode :logical Mode :logical Mode :logical Mode :logical FALSE:264 FALSE:265 FALSE:265 FALSE:265 TRUE :6 TRUE :5 TRUE :5 TRUE :5 HLY.COLUMBUS HLY.VETS HLY.THANKS HLY.XMAS Mode :logical Mode :logical Mode :logical Mode :logical FALSE:265 FALSE:265 FALSE:265 FALSE:265 TRUE :5 TRUE :5 TRUE :5 TRUE :5 HLY.ELECT HLY.PATRIOTEOMNEWMF Mode :logical Mode :logical Mode :logical Mode :logical FALSE:265 FALSE:265 FALSE:210 FALSE:263 TRUE :5 TRUE :5 TRUE :60TRUE :7 PreIO47 PreIO151PreIO164PreIO169 Mode :logical Mode :logical Mode :logical Mode :logical FALSE:269 FALSE:269 FALSE:269 FALSE:269 TRUE :1 TRUE :1 TRUE :1 TRUE :1 PreIO197PreIO203PreIO209PreIO241 Mode :logical Mode :logical Mode :logical Mode :logical FALSE:269 FALSE:269 FALSE:269 FALSE:269 TRUE :1 TRUE :1 TRUE :1 TRUE :1 PreIO261PreIO308 Mode :logical Mode :logical FALSE:269 FALSE:270 TRUE :1 (the PreIO are outliers identified from the output of stl() e.g. outliers in the source data) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories 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] faster GLS code
On Thu, 7 Jan 2010, Ravi Varadhan wrote: Try this: X - kronecker(diag(1,3),x) Y - c(y) # stack the y in a vector # residual covariance matrix for each observation covar - kronecker(sigma,diag(1,N)) csig - chol2inv(covar) betam2 - ginv(csig %*% X) %*% csig %*% Y This is more than 2 times faster than your code (however, it doesn't compute `betav') . Faster still (by a wide margin) if X will truly be of that form: B - coef(lm(y~0+.,as.data.frame(x))) all.equal( as.vector((B)), as.vector(betam)) [1] TRUE When X is of that form, the covariance matrix drops out of the computation. :) Chuck Here is a timing comparison: # Your method # GLS betas covariance matrix system.time({ inv.sigma - solve(covar) betav - solve(t(X)%*%inv.sigma%*%X) # GLS mean parameter estimates betam - betav%*%t(X)%*%inv.sigma%*%Y }) # New method system.time({ csig - chol2inv(covar) betam2 - ginv(csig %*% X) %*% csig %*% Y }) all.equal(betam, betam2) # GLS betas covariance matrix system.time({ + inv.sigma - solve(covar) + betav - solve(t(X)%*%inv.sigma%*%X) + + # GLS mean parameter estimates + betam - betav%*%t(X)%*%inv.sigma%*%Y + }) user system elapsed 1.140.511.76 system.time({ + csig - chol2inv(covar) + betam2 - ginv(csig %*% X) %*% csig %*% Y + }) user system elapsed 0.470.080.61 all.equal(betam, betam2) [1] TRUE Hope this helps, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Carlo Fezzi c.fe...@uea.ac.uk Date: Thursday, January 7, 2010 12:13 pm Subject: [R] faster GLS code To: r-help@r-project.org Dear helpers, I wrote a code which estimates a multi-equation model with generalized least squares (GLS). I can use GLS because I know the covariance matrix of the residuals a priori. However, it is a bit slow and I wonder if anybody would be able to point out a way to make it faster (it is part of a bigger code and needs to run several times). Any suggestion would be greatly appreciated. Carlo *** Carlo Fezzi Senior Research Associate Centre for Social and Economic Research on the Global Environment (CSERGE), School of Environmental Sciences, University of East Anglia, Norwich, NR4 7TJ United Kingdom. email: c.fe...@uea.ac.uk *** Here is an example with 3 equations and 2 exogenous variables: - start code -- N - 1000 # number of observations library(MASS) ## parameters ## # eq. 1 b10 - 7; b11 - 2; b12 - -1 # eq. 2 b20 - 5; b21 - -2; b22 - 1 # eq.3 b30 - 1; b31 - 5; b32 - 2 # exogenous variables x1 - runif(min=-10,max=10,N) x2 - runif(min=-5,max=5,N) # residual covariance matrix sigma - matrix(c(2,1,0.7,1,1.5,0.5,0.7,0.5,2),3,3) # residuals r - mvrnorm(N,mu=rep(0,3), Sigma=sigma) # endogenous variables y1 - b10 + b11 * x1 + b12*x2 + r[,1] y2 - b20 + b21 * x1 + b22*x2 + r[,2] y3 - b30 + b31 * x1 + b32*x2 + r[,3] y - cbind(y1,y2,y3)# matrix of endogenous x - cbind(1,x1, x2)# matrix of exogenous MODEL ESTIMATION ### # build the big X matrix needed for GLS estimation: X - kronecker(diag(1,3),x) Y - c(y) # stack the y in a vector # residual covariance matrix for each observation covar - kronecker(sigma,diag(1,N)) # GLS betas covariance matrix inv.sigma - solve(covar) betav - solve(t(X)%*%inv.sigma%*%X) # GLS mean parameter estimates betam - betav%*%t(X)%*%inv.sigma%*%Y - end of code __ R-help@r-project.org mailing list PLEASE do read the posting guide 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. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with writeBin and importing into gfortran compiled programs
On 07/01/2010 2:05 PM, jgar...@ija.csic.es wrote: Hi all, I'm having problems trying to export binary arrays from R and importing them into fortran (linux openSUSE 10.3 (x86_64), gfortran compiler, fortran 90/95 program). Let's say the problem can be expressed as: R part whini - runif(1000) writeBin(whini,fwhini.dat) f90 part PROGRAM foo INTEGER, PARAMETER :: DP = KIND(1.0D0) INTEGER :: status REAL(DP), DIMENSION(10,100) :: whini OPEN(UNIT=5, FILE='fwhini.dat', STATUS='OLD', ACTION='READ', FORM='UNFORMATTED', IOSTAT=status) READ(5) whini CLOSE(5) WRITE(*,*) whini END PROGRAM Now, if within the R session I check typeof(whini) [1] double and try whini.copy - readBin(fwhini.dat,what=double(),n=1000) the copy of whini is right. However, execution of the fortran program gives the message: Fortran runtime error: Unformatted file structure has been corrupted. I've tried also to declare whini in the fortran part as SINGLE precision, and to force writeBin using the size argument. size=4 and size=8 give the same error (whini as double in the fortran part), while size=16 gives the alternative error Fortran runtime error: I/O past end of record on unformatted file Please, could you help me with this problem? I've never used Fortran 90, so I can't tell if your type declaration is really declaring double precision values. So what I'd do is to create an array (say the values 1 to 1000) within your Fortran program, and write it out. Then do the same in R, and do a binary compare of the files to see what the differences are. The things to look for are: Size of values (4 or 8 bytes or something else). Byte order within values (big or little endian). R is very flexible in what it writes, and probably Fortran is flexible in what it can read, but you need to figure out what the differences are before you can match them up. The viewRaw() function in the hexView package is a simple way to look at the bytes in the files. 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] Building static HTML help pages in R 2.10.x on Windows
On 07/01/2010 2:16 PM, Kevin Wright wrote: Well, among other things, if my global environment becomes cluttered/corrupt/etc and I quit R, then restart R, the links in my browser are now dead. You weren't following Dieter's instructions, then. I have to close all the tabs and call help to open them again. Also, the R-supplied java tool for searching help is ancient and underwhelming. Then contribute a new one. A desktop search tool (X1/Copernic/GoogleDesktop/etc) can be very handy, but only if it has pre-built help files to index. Imperfect, stale, non-dynamic help is better than no help at all! Then fix the search tool so it can search dynamic web pages. They can be spidered too, just like static ones. Duncan Murdoch As others have done, I have switched back to 2.9.2 until I can build all help files (on Windows). Thanks to those people who are figuring out how to do this. Kevin On Thu, Jan 7, 2010 at 11:50 AM, Duncan Murdoch murd...@stats.uwo.cawrote: On 07/01/2010 11:36 AM, Jonathan Baron wrote: For what it is worth, I would gladly sacrifice this capability in order to be able to consult all my R help pages through a Firefox bookmark to the packages listing (which is what I used to do, and will do again, when I get time to either rebuild from source or get the forthcoming Fedora RPM, which will have static pages as the default), without starting an R session. What's so hard about leaving an R session running, and using bookmarks as Dieter described? Duncan Murdoch Jon On 01/07/10 10:32, Duncan Murdoch wrote: A more useful example than ls() would be methods(). I think it would be nice to have a list of methods included in the man page for a generic function, and links to their pages if they have their own man pages. You might want to list all installed methods, with some sort of highlighting to indicate which ones are already attached, or perhaps be able to toggle between installed and attached, or whatever. None of that is possible with static help, not even a list of installed methods, because someone might install a new package that offers some others after the static help has already been built. You just need to use some imagination. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Debugging issues encountered during the R CMD check process
I read through the Writing R Extensions and the Debugging in R website (http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/), looking for some hints about how to solve the issue of debugging problems encountered during the R CMD check process, but nothing seems to be mentioned about addressing issues encountered. Specifically, I am working with the R signal package which is hosted at the following location: http://code.google.com/p/r-signal/ I would like to debug the problem that is shown below, and is encountered when I run R CMD check signal. Thank you for any insights that are provided as the R signal package is nice and it would be good to have it working again with R 2.9.x and beyond. Thank you again for the help. From the 00check.log * using log directory '/Users/jasonkrupert/Documents/RStuff/Rsignal/r-signal/signal.Rcheck' * using R version 2.9.2 (2009-08-24) * using session charset: UTF-8 * checking for file 'signal/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'signal' version '0.6' * checking package dependencies ... OK * checking if this is a source package ... WARNING ### Name: interp ### Title: Interpolate / Increase the sample rate ### Aliases: interp ### Keywords: math ### ** Examples # The graph shows interpolated signal following through the # sample points of the original signal. t = seq(0, 2, by = 0.01) x = chirp(t,2,.5,10,'quadratic') + sin(2*pi*t*0.4) y = interp(x[seq(1, length(x), by = 4)],4,4,1) # interpolate a sub-sample Warning in rbind(x, array(val, dim = c(n - nx, NCOL(x : number of columns of result is not a multiple of vector length (arg 1) Warning in Fft(postpad(x, N)) * B : longer object length is not a multiple of shorter object length Error in ifft(Fft(postpad(x, N)) * B) : dims [product 36] do not match the length of object [256] Calls: interp - fftfilt - fftfiltx - ifft Execution halted __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] weight by obs # in spatial 'nest' in NLME?
Hi, I am constructing a series of nonlinear mixed regression models at multiple spatial scales on the same data. The data is a regular grid of cells. A coarser scale is achieved, for example, by aggregating cells in blocks that are 2x2 cells in dimension and averaging dependent and independent data over this block. Some 2x2 blocks will be missing data for several expected reasons and these blocks are of interest and so cannot be easily discarded (they are also likely not at random). I would like to take this into account when fitting the model. A simple weighting of each block by number of complete component observations (e.g. no missing data would have a weight of 2x2=4) seems intuitive. I've reviewed the NLME documentation and weighting schemes seem to be the usual variety of accounting for unequal variance. Is there a work around to specify the integer weights I described above? I've toyed with a work around where I duplicate each block observation by the number of observations summarized within it. Of course, this is difficult to do correctly as the sample size will be inflated and most statistics not easily interpretable. Any advice on how to proceed is welcome. Thanks. -seth -- View this message in context: http://n4.nabble.com/weight-by-obs-in-spatial-nest-in-NLME-tp1009168p1009168.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] Debugging issues encountered during the R CMD check process
On 07/01/2010 2:48 PM, Jason Rupert wrote: I read through the Writing R Extensions and the Debugging in R website (http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/), looking for some hints about how to solve the issue of debugging problems encountered during the R CMD check process, but nothing seems to be mentioned about addressing issues encountered. Specifically, I am working with the R signal package which is hosted at the following location: http://code.google.com/p/r-signal/ I would like to debug the problem that is shown below, and is encountered when I run R CMD check signal. Thank you for any insights that are provided as the R signal package is nice and it would be good to have it working again with R 2.9.x and beyond. Thank you again for the help. From the 00check.log * using log directory '/Users/jasonkrupert/Documents/RStuff/Rsignal/r-signal/signal.Rcheck' * using R version 2.9.2 (2009-08-24) * using session charset: UTF-8 * checking for file 'signal/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'signal' version '0.6' * checking package dependencies ... OK * checking if this is a source package ... WARNING ### Name: interp ### Title: Interpolate / Increase the sample rate ### Aliases: interp ### Keywords: math ### ** Examples # The graph shows interpolated signal following through the # sample points of the original signal. t = seq(0, 2, by = 0.01) x = chirp(t,2,.5,10,'quadratic') + sin(2*pi*t*0.4) y = interp(x[seq(1, length(x), by = 4)],4,4,1) # interpolate a sub-sample Warning in rbind(x, array(val, dim = c(n - nx, NCOL(x : number of columns of result is not a multiple of vector length (arg 1) Warning in Fft(postpad(x, N)) * B : longer object length is not a multiple of shorter object length Error in ifft(Fft(postpad(x, N)) * B) : dims [product 36] do not match the length of object [256] Calls: interp - fftfilt - fftfiltx - ifft Execution halted You'll often get more informative error messages in recent R releases if you set the environment variable R_KEEP_PKG_SOURCE=yes I don't know if it will help in this case. 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] regex question on escaping . (and a couple other regex questions as well)
On Jan 7, 2010, at 2:47 PM, Mark Kimpel wrote: I have an example where escaping . does not seem to be behaving consistently, but perhaps it is due to my misunderstanding. Could someone explain to me why the below produces the output it does? It seems to me that in the second example, where I am being more precise about specifying that a . (dot) should be between the numbers, should produce the same output as the first example, but it does not. there is an intervening 0 in between the matching 1-9 group and the first period causing a pattern failure for match of 160. with [1-9]+ \\. As an aside, is there a document or help page that specifies which characters need to be escaped to form regex's in R? I can't find one. ?regex # what else? Finally, how does one grep for the escape character? I've tried grep (\\, vector) grep (\\\, vector) grep(, vector) Where or perhaps what is vector? Why should we think it has an escape character in it? In some sense I think you have an epistemological problem. There can be back-slashes in strings, but they are not escape characters at that point. all without success. Thanks, Mark a - 160.15.05.00 grep([1-9]+.[0-9]+\\.[0-9]+\\.[0-0]+, a) # [1] grep([1-9]+\\.[0-9]+\\.[0-9]+\\.[0-0]+, a) # integer(0) sessionInfo() R version 2.11.0 Under development (unstable) (2009-12-28 r50849) 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] grid stats graphics grDevices datasets utils methods [8] base other attached packages: [1] Rgraphviz_1.25.1 graph_1.25.4 loaded via a namespace (and not attached): [1] tools_2.11.0 Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 399-1219 Skype No Voicemail please [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] %d/%m/%Y can not be displayed in a .rd file
Try \%d/\%m/\%Y Escaping the % should do the trick. If I remember correctly, Latex uses the % as the comment delimiter. I don't know if that's the cause of the error, but escaping it has always solve the problem for me. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of rusers.sh Sent: Thursday, January 07, 2010 2:09 PM To: r-help@r-project.org Subject: [R] %d/%m/%Y can not be displayed in a .rd file Hi all, I found the date format (e.g.%d/%m/%Y) in the .rd file cannot be displayed after building the package. See below, ###.rd file \examples{ a-10/20/1999 DateConversion(a,DateIn=%m/%d/%Y,DateOut=%d/%m/%Y) } The result is Examples: a-10-20-1999 DateConversion(a,DateIn= ??%m/%d/%Y seems cannot be recognized. Is there some method to solve this and make it visible? Thanks a lot. -- - Jane Chang Queen'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. === P Please consider the environment before printing this e-mail Cleveland Clinic is ranked one of the top hospitals in America by U.S.News World Report (2009). Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations. Confidentiality Note: This message is intended for use\...{{dropped:13}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] %d/%m/%Y can not be displayed in a .rd file
Solved. Thanks a lot. 2010/1/7 Duncan Murdoch murd...@stats.uwo.ca On 07/01/2010 2:09 PM, rusers.sh wrote: Hi all, I found the date format (e.g.%d/%m/%Y) in the .rd file cannot be displayed after building the package. See below, ###.rd file \examples{ a-10/20/1999 DateConversion(a,DateIn=%m/%d/%Y,DateOut=%d/%m/%Y) } The result is Examples: a-10-20-1999 DateConversion(a,DateIn= ??%m/%d/%Y seems cannot be recognized. Is there some method to solve this and make it visible? Thanks a lot. The % character is a comment character in Rd files. You need to escape it: DateConversion(a,DateIn=\%m/\%d/\%Y,DateOut=\%d/\%m/\%Y) Duncan Murdoch -- - Jane Chang Queen'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] Help formating data to display commas
I get this: upper - c(20, 354658, 325145) gsub(\\s, , format(upper, big.mark = ,)) [1] 200,000 354,658 325,145 On Thu, Jan 7, 2010 at 5:50 PM, Anderson, Chris chris.ander...@paradigmcorp.com wrote: When I try this all I get is NULL Chris Anderson Data Analyst Medical Affairs wk: 925-677-4870 cell: 707-315-8486 Fax:925-677-4670 -Original Message- From: Henrique Dallazuanna [mailto:www...@gmail.com] Sent: Thursday, January 07, 2010 11:45 AM To: Anderson, Chris Cc: r-help@R-project.org Subject: Re: [R] Help formating data to display commas Try this: gsub(\\s, , format(upper, big.mark = ,)) On Thu, Jan 7, 2010 at 5:31 PM, Anderson, Chris chris.ander...@paradigmcorp.com wrote: I'm using the following code to create quartile intervals of my dataset and it is working like it is suppose too. In my final output of the data I would like currency amounts to be displayed with commas. I have not found an option either through FormatC or sprintf that will display the data with commas, they only seem to add decimals. Is there a format that will display commas without me reverting to the labels statement. This is an ongoing process where the values are updated, so using the labels statement would be too much to manage. Benchparaq-levels(quantcut(benchmarkPara$Benchmark_Total, q=seq(0,1,by=0.25), na.rm=TRUE)) #,labels=c($267,000-$436,000,$436,000-$559,000,$559,000-$836,000,$836,000-$1,590,000)) lower -as.numeric(sub(\\((.+),.*, \\1, Benchparaq)) Warning: NAs introduced by coercion upper - as.numeric(sub([^,]*,([^]]*)\\], \\1, Benchparaq)) lower-ifelse(is.na(lower),0,as.numeric(lower)) upper-ifelse(is.na(upper),0,as.numeric(upper)) lower [1] 0 436000 559000 836000 upper [1] 436000 559000 836000 159 Benchparaq-paste($,lower,-,$,upper,sep=) lower-NULL upper-NULL Benchparaq [1] $0-$436000 $436000-$559000 $559000-$836000 $836000-$159 Chris Anderson Data Analyst Medical Affairs wk: 925-677-4870 cell: 707-315-8486 Fax:925-677-4670 This electronic message transmission, including any attachments, contains information which may be confidential, privileged and/or otherwise exempt from disclosure under applicable law. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this information is strictly prohibited. If you have received this electronic transmission in error, please notify the sender immediately by telephone (800-676-6777) or by a reply to sender only message and destroy all electronic and hard copies of the communication, including attachments. Thank you. For more information on Paradigm Management Services, LLC, please visit http://www.paradigmcorp.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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O This electronic message transmission, including any attachments, contains information which may be confidential, privileged and/or otherwise exempt from disclosure under applicable law. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this information is strictly prohibited. If you have received this electronic transmission in error, please notify the sender immediately by telephone (800-676-6777) or by a reply to sender only message and destroy all electronic and hard copies of the communication, including attachments. Thank you. For more information on Paradigm Management Services, LLC, please visit http://www.paradigmcorp.com -- 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.