RE: [R] Retrieve ... argument values
Ben Bolker [EMAIL PROTECTED] wrote: Yes, although this becomes tedious if (e.g.) you have a function that calls two different functions, each of which has many arguments (e.g. plot() and barplot(); then you have to set up a whole lot of arguments that default to NULL and, more annoyingly, you have to document them all in any .Rd file you create -- rather than just having a ... argument which you can say should contain arguments for either of the subfunctions (as long as the arguments don't overlap, of course) Could I suggest a very simple alternative, which extends gracefully to any number of arguments, and doesn't require you to know anything much about ... except that you can pass it to another function? f - function(...) { + has.ylim - function(..., ylim) return(!missing(ylim)) + + if (has.ylim(...)) yes else no + } f(xlim=1) [1] no f(ylim=2) [1] yes For each parameter XXX that you want to test the presence of, write has.XXX - function(..., XXX) return(!missing(XXX)) and then use has.XXX(...) in the body of the main function. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Date on x-axis of xyplot
On Wed, 2003-09-17 at 17:29, Deepayan Sarkar wrote: On Tuesday 16 September 2003 23:51, Jason Turner wrote: ... the lack of POSIXct support in the lattice graphics axes has often caused me to think up new ways around the plot. Unless I'm missing an obvious way to apply that... Actually, lattice does support POSIXct for some time now, My bad. Will check this further. Cheers Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz +64-(0)21-343-545 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Date on x-axis of xyplot
On Tue, 16 Sep 2003, Deepayan Sarkar wrote: Is the date class standard enough to warrant including a check for it in lattice ? I don't think so. The POSIX*t classes in R are the most standard, followed by the chron package and only then the date package. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] can predict ignore rows with insufficient info
On Tue, 16 Sep 2003, Peter Whiting wrote: On Tue, Sep 16, 2003 at 04:17:59PM -0400, Thomas W Blackwell wrote: Peter - Your subsequent email seems just right. You have to determine ahead of time which rows can be estimated. It seems that predict removes rows with insufficient information (ie, if I replace ALBANY with NA and refactor everything works) - I wonder why it doesn't exhibit the same behavior when it encounters a new level - just eliminate the row and go on... Somewhat related: I had been assuming (incorrectly) that length(x) would equal length(const$days) after x-predict(g,const) - this isn't the case if any of the rows of const don't contain enough info for the model. Those rows are eliminated - I'd have expected them to just be NAs in the result. That depends on the setting of option na.action: the factory-fresh default is na.omit, which is what you are seeing. As from R 1.8.0 it will use a default of na.pass for predict.lm. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Quiz {was Quit asking me ..}
Spencer == Spencer Graves [EMAIL PROTECTED] on Tue, 16 Sep 2003 19:54:22 -0700 writes: Spencer Consider Spencer Q - function(x)q(no) Spencer With R 1.7.1 under Windows, Q() caused R to close Spencer without asking for confirmation. This does not Spencer solve the whole problem, but it might provide a Spencer piece of the puzzle. Apropos, this reminds me of the old quiz (from the S-plus times): How can you write (quite short!) R code such that typing Q -- without any () -- will quit R (without asking about saving). [But you shouldn't really keep that code active in your standard R session because it would be too easy to accidentally shut down R !] For the advanced ones: My shortest solution uses 51 characters of R code, can you beat that? -- Martin Maechler [EMAIL PROTECTED] http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] calculation of the p value in ks.test()
Rajarshi Guha wrote: Hi, I'm working with the ks.test() function and I have also implemented the test using Conover as the reference. My D value matches that produced by R. However to calculate the p value I am using the code described in Numerical Recipes in C++ (2nd Ed.) pg 631. The p value produced by the NRC code is generally larger than that produced by R by a factor of 10. Currently I am not in a position to download the R source and look at it - lack of space :( Cannot believe: Lack of *_space_*??? has anybody used the NRC code? The text mentions that it calculates the sum Q(L) = 2 \sum^{-\infty}_{j=1} (-1)^(j-1) \exp^{-2 j^2 L^2} and the value of L is given by [ sqrt(n) + 0.12 + 0.11 / sqrt(n) ] * D where n = n1*n2/(n1+n2) .. n1, n2 are lengths of the vectors and D is the calculated statistic. Is this the same definition as used in R? No. Since you have a working copy of R (obviously a binary version?), you only need the file ks.c. If that 3kB file won't flood your harddisk, I'll send it in a private message. Uwe Ligges __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Using POSIX?t rather than chron or date
BDR == Prof Brian Ripley [EMAIL PROTECTED] on Wed, 17 Sep 2003 06:58:48 +0100 (BST) writes: BDR On Tue, 16 Sep 2003, Deepayan Sarkar wrote: Is the date class standard enough to warrant including a check for it in lattice ? BDR I don't think so. The POSIX*t classes in R are the BDR most standard, followed by the chron package and only BDR then the date package. Definitely. And I think we should encourage people to upgrade to POSIX.t from chron (let alone date) more strongly {Note that there have been as.POSIXct() methods for these classes since the beginning of the POSIX.t classes. Could chron and date users be heard about what functionality they are missing in POSIX.t ? On the other hand, the recommended package survival has a(nother?) class date and that package is based on S(plus) code and may hence not be convertible sensibly ? Martin Maechler [EMAIL PROTECTED] http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Quiz {was Quit asking me ..}
Martin Maechler wrote: Spencer == Spencer Graves [EMAIL PROTECTED] on Tue, 16 Sep 2003 19:54:22 -0700 writes: Spencer Consider Spencer Q - function(x)q(no) Spencer With R 1.7.1 under Windows, Q() caused R to close Spencer without asking for confirmation. This does not Spencer solve the whole problem, but it might provide a Spencer piece of the puzzle. Apropos, this reminds me of the old quiz (from the S-plus times): How can you write (quite short!) R code such that typing Q -- without any () -- will quit R (without asking about saving). [But you shouldn't really keep that code active in your standard R session because it would be too easy to accidentally shut down R !] For the advanced ones: My shortest solution uses 51 characters of R code, can you beat that? Less than 51 is not that hard, Martin: 46 (counting line breaks as characters): Q-1 class(Q)-Q print.Q-function(x)q(no) Uwe __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Quiz {was Quit asking me ..}
MM == Martin Maechler [EMAIL PROTECTED] on Wed, 17 Sep 2003 08:36:19 +0200 writes: Spencer == Spencer Graves [EMAIL PROTECTED] on Tue, 16 Sep 2003 19:54:22 -0700 writes: Spencer Consider Spencer Q - function(x)q(no) Spencer With R 1.7.1 under Windows, Q() caused R to close Spencer without asking for confirmation. This does not Spencer solve the whole problem, but it might provide a Spencer piece of the puzzle. MM Apropos, this reminds me of the old quiz (from the S-plus times): MM How can you write (quite short!) R code such that MM typing MM Q MM -- without any () -- will quit R (without asking about saving). MM [But you shouldn't really keep that code active in your MM standard R session because it would be too easy to MM accidentally shut down R !] MM For the advanced ones: My shortest solution uses 51 MM characters of R code, can you beat that? I had overlooked something: Uwe Ligges and Deepayan Sarkar beat it almost simultaneously with a solution of 43 characters (when using = for assignment). Martin __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Quiz {was Quit asking me ..}
On Wednesday 17 September 2003 01:36, Martin Maechler wrote: How can you write (quite short!) R code such that typing Q -- without any () -- will quit R (without asking about saving). [But you shouldn't really keep that code active in your standard R session because it would be too easy to accidentally shut down R !] For the advanced ones: My shortest solution uses 51 characters of R code, can you beat that? Barely, 46 removing all spaces: print.q-function(x)q(no);Q-1;class(Q)-q We can also replace - by = in recent (and _ in older) versions of R to decrease this further. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Quiz {was Quit asking me ..}
First, 42 characters... Q=no;class(Q)=Q;print.no=function(x)q(Q) Interestingly, the following works too (41 chars) Q=;class(Q)=Q;print.=function(x)q(no) Is it legal though to have empty class names? And finally, the beautiful one with 28 characters Q=no;class(Q)=Q;print.no=q Have nice day! Henrik Bengtsson Lund University -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Deepayan Sarkar Sent: den 17 september 2003 09:17 To: Martin Maechler; [EMAIL PROTECTED] Subject: Re: [R] Quiz {was Quit asking me ..} On Wednesday 17 September 2003 01:36, Martin Maechler wrote: How can you write (quite short!) R code such that typing Q -- without any () -- will quit R (without asking about saving). [But you shouldn't really keep that code active in your standard R session because it would be too easy to accidentally shut down R !] For the advanced ones: My shortest solution uses 51 characters of R code, can you beat that? Barely, 46 removing all spaces: print.q-function(x)q(no);Q-1;class(Q)-q We can also replace - by = in recent (and _ in older) versions of R to decrease this further. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo /r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] R-Golf {was Quiz {was Quit asking me ..}}
Deepayan Sarkar wrote: Barely, 46 removing all spaces: print.q-function(x)q(no);Q-1;class(Q)-q We can also replace - by = in recent (and _ in older) versions of R to decrease this further. This is 'R-golf'. Perl golf competitions are quite common and usually result in seriously obfuscated code. Perhaps someone would like to run an R-golf contest for the R-newsletter (crossword fans: solution to the crossword I set in the last one is coming in the next R-newsletter)? Perl golf contests are run from here [http://perlgolf.sourceforge.net] if you want inspiration. Baz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Quiz {was Quit asking me ..}
Sorry for bugging you AGAIN, but I went to get a coffee and I realized you can get down to 26 characters: class(Q)=Q=no;print.no=q That is a good question to put up on an R/parsing/S3/UseMethod quiz, ehe?! Henrik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Henrik Bengtsson Sent: den 17 september 2003 10:18 To: 'Deepayan Sarkar'; 'Martin Maechler'; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: [R] Quiz {was Quit asking me ..} First, 42 characters... Q=no;class(Q)=Q;print.no=function(x)q(Q) Interestingly, the following works too (41 chars) Q=;class(Q)=Q;print.=function(x)q(no) Is it legal though to have empty class names? And finally, the beautiful one with 28 characters Q=no;class(Q)=Q;print.no=q Have nice day! Henrik Bengtsson Lund University -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Deepayan Sarkar Sent: den 17 september 2003 09:17 To: Martin Maechler; [EMAIL PROTECTED] Subject: Re: [R] Quiz {was Quit asking me ..} On Wednesday 17 September 2003 01:36, Martin Maechler wrote: How can you write (quite short!) R code such that typing Q -- without any () -- will quit R (without asking about saving). [But you shouldn't really keep that code active in your standard R session because it would be too easy to accidentally shut down R !] For the advanced ones: My shortest solution uses 51 characters of R code, can you beat that? Barely, 46 removing all spaces: print.q-function(x)q(no);Q-1;class(Q)-q We can also replace - by = in recent (and _ in older) versions of R to decrease this further. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo /r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo /r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] attributing names in predicted type=terms gam object
Hi, suppose i have a gam object gamobject- gam( Y~ s(X1)+s(X2)+ X3) I would like to extract the predicted partial effect of X3 but selecting it by its name, as it's to be included in a function and i don't always know the exact position of X3. something like predict(gamobject,type=terms)[X3,]. But that doesn't work as there's no name. So, looking at the object i get when using predict(gamobject, type=terms), i would like to name the rows of that object that reflect the original formula, something close to the output from predict.gam in S-plus. Any ideas? thanks O__ Alain Le Tertre c/ /'_ --- Institut de Veille Sanitaire (InVS) (*) \(*) -- 12 rue du val d'Osne ~~ - 94415 Saint Maurice cedex FRANCE Voice: 33 1 41 79 67 50 Fax: 33 1 41 79 67 68 email: [EMAIL PROTECTED] [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Using POSIX?t rather than chron or date
On Wed, 17 Sep 2003, Martin Maechler wrote: BDR == Prof Brian Ripley [EMAIL PROTECTED] on Wed, 17 Sep 2003 06:58:48 +0100 (BST) writes: BDR On Tue, 16 Sep 2003, Deepayan Sarkar wrote: Is the date class standard enough to warrant including a check for it in lattice ? BDR I don't think so. The POSIX*t classes in R are the BDR most standard, followed by the chron package and only BDR then the date package. Definitely. And I think we should encourage people to upgrade to POSIX.t from chron (let alone date) more strongly {Note that there have been as.POSIXct() methods for these classes since the beginning of the POSIX.t classes. Could chron and date users be heard about what functionality they are missing in POSIX.t ? On the other hand, the recommended package survival has a(nother?) class date and that package is based on S(plus) code and may hence not be convertible sensibly ? survival has the parts of date it needs included (same class, same original author). It has rate tables which as I understand it are in date format and so need to accessed by date objects. I could well understand Thomas not wanting to do a conversion. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Text Vector Printing And Storage
I am using R 1.7.1 on Windows, running a program on a daily basis which produces a vector of text results, where the length of the vector may be different each day. While I can display this vector in the R console using a cat instruction, I am presently unable to either print it out on a printer (item 2.9 in the R for Windows FAQ says I need to use 'File | Print' but I've failed to find any function listed under that name), or to store this vector in a textfile alongside previous days' results because they are not all of the same length and cannot therefore be collectively handled as a matrix or dataframe. Any help with regard to either of these problems would be greatly appreciated! Phil [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] arma.roots
Hi, I am looking for a time series function called arma.roots and I can't find it. This function compute the roots of a MA or AR defining polynomial and display graphically. Thanks Usman - Want to chat instantly with your online friends? Get the FREE Yahoo!Messenger [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Using POSIX?t rather than chron or date
Martin Maechler [EMAIL PROTECTED] wrote: Could chron and date users be heard about what functionality they are missing in POSIX.t ? As a chron user, I suppose none. But I find chron more friendly and it saves some typing. In my opinion, as.POSIXct and most related functions have rather complicated names to type, which make them prone to typos. Typos slow down the thinking. -- Philippe Glaziou Pasteur Institute of Cambodia __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: Just don't do it, surely? (was RE: [R] Retrieve ... argument values)
On Wed, 17 Sep 2003, Simon Fear wrote: There have been various elegant solutions to test for the presence of a particular named parameter within a ... argument, such as if (!is.null(list(...)$ylim)) if (ylim %in% names(list(...))) I think I'd have to comment these lines pretty clearly if I wanted to easily follow the code in 6 months time. Well, take a look at the R sources, as dots - list(...) haveYlim - ylim %in% names(dots) is the sort of thing we still understand 5 years later. But I'm still not convinced it is ever a good idea to use this technique in preference to using explicit named arguments. If there is something special about ylim, why insist that it be passed within ... in the first place? Surely it's better to define the function as function(x,ylim=default,...) within which you do your special ylim stuff, then call plot(x, ylim=ylim,...))?? Can anyone come up with a good reason not to follow that principle? Inadvertent partial matching for one. If you must do this, put ylim after ... or anything you try to pass through ... starting y, yl or yli will be matched to ylim, as in foo - function(x, ylim=NULL, ...) match.call() foo(y=1) foo(ylim = 1) foo - function(x, ..., ylim=NULL) match.call() foo(y=1) foo(y = 1) Were you aware of that? (It's not clear to me that a lot of authors of R code have considered it carefully. It is in `S Programming'.) I think my earlier post may have been misconstrued: I'm not saying never write functions that use ..., I'm just saying never write functions that depend on a particular argument being passed via It is also conceptually simpler for groups of arguments, such as graphical parameters, to be treated consistently, possibly between groups of functions. See plot.POSIXct for one of the possible elegant workarounds. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Persp and color (again)
Hi guys, After all the discussion yesterday about persp and color, I decided to have a more closer look at demo(persp), and decided to write a function to generate 'topo-like' colours to plot perspectives (Thanks a lot to Uwe Ligges for his enlightning comments regarding the code in the demo). Here it goes, I believe that this function will be pretty useful to a lot of people: ### # Function to generate a matrix of colors to be used in perspective plots # (based on demo(persp) and the comments of U. Ligges ### surf.colors - function(x, col = terrain.colors(20)) { # First we drop the 'borders' and average the facet corners # we need (nx - 1)(ny - 1) facet colours! x.avg - (x[-1, -1] + x[-1, -(ncol(x) - 1)] + x[-(nrow(x) -1), -1] + x[-(nrow(x) -1), -(ncol(x) - 1)]) / 4 # Now we construct the actual colours matrix colors = col[cut(x.avg, breaks = length(col), include.lowest = T)] return(colors) } # Now lets look at an example of using it: # first lets build some random surface library(MASS) x - cbind(rnorm(100), rnorm(100)) x - kde2d(x[,1], x[,2], n = 100)$z # now lets plot it! par(bg = gray) persp(x, col = surf.colors(x), phi = 30, theta = 225, box = F, border = NA, shade = .4) persp(x, col = surf.colors(x, col = heat.colors(40)), phi = 30, theta = 225, box = F, border = NA, shade = .4) persp(x, col = surf.colors(x, col = topo.colors(40)), phi = 30, theta = 225, box = F, border = NA, shade = .4) persp(x, col = surf.colors(x, col = gray(seq(0, 1, len = 40))), phi = 30, theta = 225, box = F, border = NA, shade = .4) # etc, etc, etc. I hope this will give you plenty of ideas, perhaps, the writer of persp would like to # add this as a subroutine so it can be called directly from within the persp function, say # persp(x, col = heat.colors(20), topo = TRUE, ...) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Fractals in R and having fun! (and more persp and color)
Well, I started playing with fractals in R, and wrote a function to generate de Mandelbrot set, which might be of interest to some people ### # Mandelbrot set ### mandelbrot - function(x = c(-3.0, 1.0), # x coordinates y = c(-1.8, 1.8), # y coordinates b = .05,# by 'steps' iter = 20) # maximum number of iterations { m = NULL # will store the results, this is the 'image' matrix for(i in seq(x[1], x[2], by = b)) { r = NULL # stores part of the iteration results for(j in seq(y[1], y[2], by = b)) { it = iter # will hold iteration at which point (i, j) breaks off c = c(i, j) # initial point z = c(i, j) # i: real part; j: imaginary part for(k in 1:iter) { # the Mandelbrot iteration formulae: z - z*z + c z = c(z[1]^2 - z[2]^2, 2 * z[1]*z[2]) + c # tests if point breaks off if((z[1] + z[2])^2 4) { it = k; break } } r = c(r, it) # stores iteration results } # constructs the 'image' matrix m = rbind(m, r) } # the output fractal object fractal = list(x = seq(x[1], x[2], by = b), # x coordinates y = seq(y[1], y[2], by = b), # y coordinates z = m)# it matrix } ## # here goes how it works ## frac - mandelbrot() image(frac) # perhaps not very nice! # more resolution, beware, this might take some time to calculate frac - mandelbrot(b = .01) image(frac) # now here comes the fun, lets do a persp plot of the set! persp(log(frac$z), border = NA, theta = 225, phi = 45, col = gray, shade = .4) ###END### Well, here comes what would have been my question. How to put some nice colors to the above perspective plot? I wanted to post this question some weeks ago, but it was answered yesterday after all the discussion on persp and colors. If you see my previous post, you'll the definition of surf.colors used below: persp(log(frac$z), border = NA, theta = 225, phi = 45, col = surf.colors(frac$z, col = c(gray(seq(0.5, 1, len = 39)), black)), shade = .4) that was what I always wanted to do, and this was the source of my confusion when checking the code in persp demo. But now some new question arises, which I'll leave to the interested hacker: Any C programmer who volunteers to write and link c code to R to calculate de Mandelbrot set faster? Does anyone have any idea on how to 'smooth' the valleys and ridges that rise towards the set?, i.e. to avoid the stairs like appearence of the plot? I hope you can have some fun with this! __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Text Vector Printing And Storage
how about: ?write something like: your.text - c(date(), insert name of your R object, end ) write(your.text, your-text.txt, append=TRUE) date() and end should help you to separate your daily changing character vectors. HTH, Bernhard I am using R 1.7.1 on Windows, running a program on a daily basis which produces a vector of text results, where the length of the vector may be different each day. While I can display this vector in the R console using a cat instruction, I am presently unable to either print it out on a printer (item 2.9 in the R for Windows FAQ says I need to use 'File | Print' but I've failed to find any function listed under that name), File | Print works fine for me; have you checked your printer settings? or to store this vector in a textfile alongside previous days' results because they are not all of the same length and cannot therefore be collectively handled as a matrix or dataframe. how about: ?write something like: your.text - c(date(), insert name of your R object, end ) write(your.text, your-text.txt, append=TRUE) date() and end should help you to separate your daily changing character vectors. HTH, Bernhard Any help with regard to either of these problems would be greatly appreciated! Phil [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- If you have received this e-mail in error or wish to read our e-mail disclaimer statement and monitoring policy, please refer to http://www.drkw.com/disc/email/ or contact the sender. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: Just don't do it, surely? (was RE: [R] Retrieve ... argument values)
Thanks for the insight. -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] snip dots - list(...) haveYlim - ylim %in% names(dots) is the sort of thing we still understand 5 years later. I didn't say understand, I said easily follow. Obviously how easily is subjective and depends to some extent on frequency of use of this idiom. snip Inadvertent partial matching for one. Ah yes! It is true that I often forget about this, mostly because partial argument matching offends me greatly, and I never, knowingly, use it. Of course as a major contributor to the R project (and that's an understatement, I know), you do have to worry about this - users of your routines may like to use partial matching. But I hope most of us don't. Worse news is that my posted formulation would suffer the same problem if I had an explicit argument ylimit and called with a ylim in ... intended for par. That's just too horrible to contemplate. Simon Fear Senior Statistician Syne qua non Ltd Tel: +44 (0) 1379 69 Fax: +44 (0) 1379 65 email: [EMAIL PROTECTED] web: http://www.synequanon.com Number of attachments included with this message: 0 This message (and any associated files) is confidential and\...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Is calculating a Lake Ratio possible with R?
If I display a line chart, with peaks and valleys, and visualize rain falling on a mountain range, filling in all the valleys. This produces a series of lakes between peaks. In case the highest peak s not at the right most edge, erect a dam on the right to back up the water to the highest peak, at the far right to collect all the water from the previous high point in a final, artificial lake. Now calculate the total volume and the volume of the land mass. If we divide the total volume of water by the volume of the earth below it, we have the Lake Ratio. If someone has done something similar to this please let me know. Thanks Lawrence __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R]gam and concurvity
in the paper Avoiding the effects of concurvity in GAM's .. of Figueiras et al. (2003) it is mentioned that in GLM collinearity is taken into account in the calc of se but not in GAM (- results in confidence interval too narrow, p-value understated, GAM S-Plus version). I haven't found any references to GAM and concurvity or collinearity on the R page. And I wonder if the R version of Gam differ in this point. - the penalized regression spline representation means that it's easy to calculate the `correct' s.e.'s and this is what is done. The covariance matrix used is based on a Bayesian model of smoothing, generalized from Silverman (1985), JRSSB (and less closely, Wahba, 1983, JRSSB), so the s.e.'s are generally a little larger than you'd get if you just pretended that the GAM was an un-penalized GLM (this widening generally improves CI performance). As Thomas Lumley pointed out, the s.e.'s don't take into account smoothing parameter estimation uncertainty. In simulation studies this uncertainty seems to have very little effect on the realized coverage probabilities of Confidence Interval's that are in some sense `whole model' intervals, but the performance of CI's for component functions of the GAM can be quite a long way from nominal. There's a simple `not-very-computer-intensive' fix for this which removes the conditioning on the smoothing parameters and greatly improves component-wise coverage probabilities implementation is on my `to-do' list (might wait to see what the referees say though!) Simon ps. mgcv 0.9 out now! (changes list linked to my www page) _ Simon Wood [EMAIL PROTECTED]www.stats.gla.ac.uk/~simon/ Department of Statistics, University of Glasgow, Glasgow, G12 8QQ Direct telephone: (0)141 330 4530 Fax: (0)141 330 4814 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] 3D plot/surface rotation
Hello MZodet, Wednesday, September 17, 2003, 2:14:12 PM, you wrote: Mag How do I rotate 3D plots/surfaces generated by either cloud or wireframe? wireframe has the screen parameter which reads a list to rotate ... something in this kind: wireframe(object, screen = list( x = 5, y = 5 , z= 10)) Same with cloud function... __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] problems making R 1.7.1
Hi, I'm building R 1.7.1 in a SuSE 8.2 box with the updated compiler from SuSE (gcc 3.1.1-16) and I'm getting this error: making dataentry.d from dataentry.c In file included from /usr/X11R6/include/X11/keysym.h:73, from dataentry.c:36: /usr/X11R6/include/X11/keysymdef.h:1181:2: invalid preprocessing directive #d making devX11.d from devX11.c making rotated.d from rotated.c making rbitmap.d from rbitmap.c make[4]: Leaving directory `/usr/local/src/compile/R-1.7.1/src/modules/X11' make[4]: Entering directory `/usr/local/src/compile/R-1.7.1/src/modules/X11' gcc -I. -I../../../src/include -I../../../src/include -I/usr/X11R6/include -I/usr/local/include -DHAVE_CONFIG_H -D__NO_MATH_INLINES -mieee-fp -fPIC -g -O2 -c dataentry.c -o dataentry.lo In file included from /usr/X11R6/include/X11/keysym.h:73, from dataentry.c:36: /usr/X11R6/include/X11/keysymdef.h:1181:2: invalid preprocessing directive #d make[4]: *** [dataentry.lo] Error 1 make[4]: Leaving directory `/usr/local/src/compile/R-1.7.1/src/modules/X11' make[3]: *** [R] Error 2 make[3]: Leaving directory `/usr/local/src/compile/R-1.7.1/src/modules/X11' make[2]: *** [R] Error 1 make[2]: Leaving directory `/usr/local/src/compile/R-1.7.1/src/modules' make[1]: *** [R] Error 1 make[1]: Leaving directory `/usr/local/src/compile/R-1.7.1/src' make: *** [R] Error 1 Can someone help me on this ? Thanks EJ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] mgcv 0.9 install
ps. mgcv 0.9 out now! (changes list linked to my www page) Hello, I tried to update mgcv but it doesn't work update.packages() mgcv : Version 0.8-9 in /usr/lib/R/library Version 0.9-2 on CRAN Update (y/N)? y trying URL `http://cran.r-project.org/src/contrib/mgcv_0.9-2 .tar.gz' Content type `application/x-tar' length 180772 bytes opened URL .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. downloaded 176Kb * Installing *source* package 'mgcv' ... ** libs gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wa ll -pedantic -fPIC -g -O2 -c gcv.c -o gcv.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wa ll -pedantic -fPIC -g -O2 -c magic.c -o magic.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wa ll -pedantic -fPIC -g -O2 -c mat.c -o mat.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wa ll -pedantic -fPIC -g -O2 -c matrix.c -o matrix.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wa ll -pedantic -fPIC -g -O2 -c mgcv.c -o mgcv.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wa ll -pedantic -fPIC -g -O2 -c qp.c -o qp.o gcc -I/usr/lib/R/include -D__NO_MATH_INLINES -mieee-fp -Wa ll -pedantic -fPIC -g -O2 -c tprs.c -o tprs.o gcc -shared -o mgcv.so gcv.o magic.o mat.o matrix.o mgcv.o qp.o tprs.o -L/usr/lib/R/bin -lRlapack -lf77blas -latlas -L/ usr/lib/gcc-lib/i386-linux/3.3 -L/usr/lib/gcc-lib/i386-linux /3.3/../../.. -lfrtbegin -lg2c-pic -lm -lgcc_s -L/usr/lib/R /bin -lR /usr/bin/ld: cannot find -lf77blas collect2: ld returned 1 exit status make: *** [mgcv.so] Fehler 1 ERROR: compilation failed for package 'mgcv' Delete downloaded files (y/N)? y Warning message: Installation of package mgcv had non-zero exit status in: in stall.packages(update[, Package], instlib, contriburl = co ntriburl, Martin __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] 3D plot/surface rotation
[EMAIL PROTECTED] wrote: How do I rotate 3D plots/surfaces generated by either cloud or wireframe? wireframe - I think you have to set the screen parameter, see the example from ?wireframe, it seems to me you can rotate the surface as you like. I believe it's the same thing for cloud, but I did not test it. I don't know if it's possible for you but persp is also good for 3D surfaces. Then you just have to set the theta and phi parameters. Hope this helps, Laurent __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] mstree
hello, i have some problems with mstree! there are no similar function in R like in S-Plus! Is there somebody who has a code in R Thanks __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] R courses in germany
Starting in November, a short series of R courses will take place at the University of Hanover. The topics will include * Introduction to Data Analysis with R (T. Hothorn, U. Ligges, A. Zeileis) * Programming with R (K. Hornik, F. Leisch) * Mixed Models in S (J. Pinheiro) More details are given at http://www.bioinf.uni-hannover.de/R-Kurse/ Best, Torsten ___ | | | Dr. rer. nat. Torsten Hothorn | | Institut fuer Medizininformatik, Biometrie und Epidemiologie| | Waldstrasse 6, D-91054 Erlangen, Deutschland| | Tel: ++49-9131-85-22707 | | Fax: ++49-9131-85-25740 | | Email: [EMAIL PROTECTED] | | Web: http://www.imbe.med.uni-erlangen.de/~hothorn | |___| __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R]Bivariate Ripley K function
Hello, I have used the univariate Ripley K function in R, but does anyone know if there is a bivariate function built in? I have two species that I am dealing with. Also, how might I add error bars into the graphs (univariate and/or bivariate)? Thank you, Karin Leiderman [EMAIL PROTECTED] Graduate Student/Research Assistant Department of Mathematics Univesity of New Mexico _ Get 10MB of e-mail storage! Sign up for Hotmail Extra Storage. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] 3D plot/surface rotation
Perhaps MZodet wants the interactive, mouse controlled rotation capability offered by ggobi www.ggobi.org ? Designed for linux but advertises better portability to Microsoft Windows. I have no experience myself either installing or using this. - tom blackwell - u michigan medical school - ann arbor - Wednesday, September 17, 2003, 2:14:12 PM, MZodet wrote: How do I rotate 3D plots/surfaces generated by either cloud or wireframe? On Wed, 17 Sep 2003, Mark Marques wrote: wireframe has the screen parameter which reads a list to rotate ... something in this kind: wireframe(object, screen = list( x = 5, y = 5 , z= 10)) Same with cloud function... __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Re: mgcv 0.9 install
/usr/bin/ld: cannot find -lf77blas - this is the problem, the linker can't find the basic linear algebra system library on your machine (I'm surprised R can be built without this). I think you may need to install the atlas package, but am not sure: hopefully someone else will know... Simon __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] gnls( ) question
Thank you! Using control = gnlsControl(...) has made a difference in several of my model calls [no other change needed, except that gnlsControl(...) does not accept pnlsTol or pnlsMaxIter options]. For several other model calls, fiddling with the intial parameter estimates helped. Best, david paul -Original Message- From: Jesus Frias [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 10:35 AM To: Paul, David A; R help Subject: RE: [R] gnls( ) question Hi Paul, The message has to do with the gauss-newton algorithm and it announces that there will be a failure in convergence. An old version of the algorithm is in Bates and Watts Nonlinear regression and its applications (one of the appendix). When I get that kind of messages, it can mean two things: 1.-The initial estimates that I have provided are not good enough. You can try to get some good estimates using optim(). 2.-The model that I am trying to fit is not appropriate to describe the data. No straight-forward solution goes for this. If you want to fiddle around with the parameters of gnls and try to see if you reach convergence from your model and starting points, have a look at the gnls page and the gnlsControl help pages. I think you need to specify inside your gnls() call control =gnlsControl(maxIter = 1000, pnlsMaxIter = 200, msMaxIter = 1000, tolerance = 1e-06, pnlsTol = 1e-04, msTol = 1e-07, minScale = 1e-10, returnObject = TRUE) best regards, IOsu P.S.: That gnls function is a superb addition to the nonlinear regression facilities R had before!. -- Jesús María Frías Celayeta School of Food Sci. and Env. Health. Faculty of Tourism and Food Dublin Institute of Technology Cathal Brugha St., Dublin 1. Ireland Phone: +353 1 4024459 Fax: +353 1 4024495 http://www.dit.ie/DIT/tourismfood/science/staff/frias.html -- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Paul, David A Sent: 16 September 2003 16:19 To: '[EMAIL PROTECTED]' Subject: [R] gnls( ) question Last week (Wed 9/10/2003, regression questions) I posted a question regarding the use of gnls( ) and its dissimilarity to the syntax that nls( ) will accept. No one replied, so I partly answered my own question by constructing indicator variables for use in gnls( ). The code I used to construct the indicators is at the end of this email. I do have a nagging, unanswered question: What exactly does Warning message: Step halving factor reduced below minimum in NLS step in: gnls(model = y ~ 5 + ...) mean? I have tried to address this by specifying control = list(maxIter = 1000, pnlsMaxIter = 200, msMaxIter = 1000, tolerance = 1e-06, pnlsTol = 1e-04, msTol = 1e-07, minScale = 1e-10, returnObject = TRUE) in my model calls, but this does not entirely eliminate the problem (I am running gnls( ) 24 separate times on separate data sets). Much thanks in advance, david paul #Constructing Indicator Variables indicator - paste( foo$X - sapply(foo$subject.id, FUN = function(x) if(x == X) 1 else 0) ) indicator - parse( text = indicator )[[1]] subjectID.foo - as.factor(as.character(unique(foo$animal.id))) for(i in subjectID.foo) { INDICATOR - do.call(substitute, list(indicator, list(i = i, X = as.character(subjectID.foo[i] eval(INDICATOR) } foo$Overall.Effect - rep(1,length(foo$dose.group)) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- This message has been scanned for content and viruses by the DIT ICT Services MailScanner Service, and is believed to be clean. http://www.dit.ie -- This message has been scanned for content and viruses by the DIT ICT Services MailScanner Service, and is believed to be clean. http://www.dit.ie __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] all possible samples
Dear all, there is an R function that return all possible samples of size n, with replacement, from a vector of length N ? Best regards __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] 3D plot/surface rotation
Thomas W Blackwell wrote: Perhaps MZodet wants the interactive, mouse controlled rotation capability offered by ggobi www.ggobi.org ? Designed for linux but advertises better portability to Microsoft Windows. I have no experience myself either installing or using this. In that case we might want to point MZodet to the packages djmrgl (only on Windows, by Duncan Murdoch, http://www.stats.uwo.ca/faculty/murdoch/software/default.htm) and rgl (don't know its current state of development, by D. Adler and O. Nenadic, http://wsopuppenkiste.wiso.uni-goettingen.de/~dadler/rgl/) as well. Uwe Ligges - tom blackwell - u michigan medical school - ann arbor - Wednesday, September 17, 2003, 2:14:12 PM, MZodet wrote: How do I rotate 3D plots/surfaces generated by either cloud or wireframe? On Wed, 17 Sep 2003, Mark Marques wrote: wireframe has the screen parameter which reads a list to rotate ... something in this kind: wireframe(object, screen = list( x = 5, y = 5 , z= 10)) Same with cloud function... __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] A question on seasonal time series - R package
Hi there, I am using the ts class of the R package. I have a data file containing a time series of 1152 entries. It is actually 4 days data cascaded together where the time interval of data collected is 5 minutes. Thus, I have 288 values per day. When I am trying to fit this data using a period of 288 with a seasonal model, using the arima(...) function, I am getting error message Error: makeARIMA(...): negative length vectors are not allowed. I am not sure what is the problem. I really appreciate some help on this. Thanks in advance. -Balaji. -- Two roads diverged in a wood and I took the one less traveled by and, that has made all the difference -- Robert Frost Balaji Krithikaivasan (PhD Student), [Co]mputer [N]etworking [Re]search [L]ab (CoNReL) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Generating a point pattern
I have a stem map of trees that are different from CSR at distances of 10-15 meters on a hectare plot. There are about 100 stems per ha. I want to generate a point pattern that replicates this for a model. So, about 100 trees in a 100 x 100 space that are clustered at distances from 10-15 meters. Is this possible in R? Is there something similar to make.pattern in S+? I've been messing with splancs but since I don't want a cluster process (at least I don't think I do), I'm a bit lost. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] R compiled on IBM p690?
Hello, We had all kinds of trouble of compiling/running R correctly on IBM p690. Anybody have successfully experience and would like to share with us? Please reply me personally (see my email address below), since I am not subscribing this mailing list. Thanks a lot! Simon = Simon M. Lin, M.D. Assistant Research Professor of Biostatistics and Bioinformatics and Manager of Duke Bioinformatics Shared Resource Box 3958, Duke University Medical Center Durham, NC 27710 Ph: (919) 681-9646 FAX: (919) 681-8028 Lin00025 (at) mc.duke.edu http://dbsr.duke.edu __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: Just don't do it, surely? (was RE: [R] Retrieve ... argument values)
At Wednesday 11:19 AM 9/17/2003 +0100, Simon Fear wrote: There have been various elegant solutions to test for the presence of a particular named parameter within a ... argument, such as if (!is.null(list(...)$ylim)) if (ylim %in% names(list(...))) I think I'd have to comment these lines pretty clearly if I wanted to easily follow the code in 6 months time. But I'm still not convinced it is ever a good idea to use this technique in preference to using explicit named arguments. If there is something special about ylim, why insist that it be passed within ... in the first place? Surely it's better to define the function as function(x,ylim=default,...) within which you do your special ylim stuff, then call plot(x, ylim=ylim,...))?? Can anyone come up with a good reason not to follow that principle? I think my earlier post may have been misconstrued: I'm not saying never write functions that use ..., I'm just saying never write functions that depend on a particular argument being passed via Several reasons for not following that principle involve proliferation of defaults -- if the lower level functions have defaults, then those defaults must be repeated at the higher levels. This is a good reason for not following that principle, because it makes software maintenance more difficult. Another reason for not following that principle is that tf you have several lower level functions with different default values for an argument of the same name, it becomes impossible to get the lower-level default behavior. -- Tony Plate __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] all possible samples
I am not sure if this is the easiest way, but you can do something like this: library(gregmisc) combinations(N, n, x, repeats=TRUE) where x is an atomic vector of size N. The only restriction is that the x vector has to have N unique elements. The combinations function will return a matrix with n columns containing the combinations. The combinations function is defined recursively. Even for moderate values of N and n it will either take a long time or bomb out with the evaluation is nested too deeply error. For example, on my modest machine (PIII 1GHz with 1/5 Gbyte of memory) it takes almost a minute to evaluate combinations(30, 6, repeats=TRUE) (1623160 combinations) and combinations(44, 2, repeats=TRUE) (only 990 combinations) bombs out. If you need to work with larger numbers you will probably need a sequential code. Hope this helps, Andy __ Andy Jaworski Engineering Systems Technology Center 3M Center, 518-1-01 St. Paul, MN 55144-1000 - E-mail: [EMAIL PROTECTED] Tel: (651) 733-6092 Fax: (651) 736-3122 |-+ | | lamack lamack | | | [EMAIL PROTECTED]| | | Sent by: | | | [EMAIL PROTECTED]| | | ath.ethz.ch | | || | || | | 09/17/2003 09:52 | | || |-+ -| | | | To: [EMAIL PROTECTED] | | cc: | | Subject: [R] all possible samples | -| Dear all, there is an R function that return all possible samples of size n, with replacement, from a vector of length N ? Best regards __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: Just don't do it, surely? (was RE: [R] Retrieve ... argument values)
Tony, I don't understand what you mean. Could you give an example? -Original Message- From: Tony Plate [mailto:[EMAIL PROTECTED] ... I'm not saying never write functions that use ..., I'm just saying never write functions that depend on a particular argument being passed via Several reasons for not following that principle involve proliferation of defaults -- if the lower level functions have defaults, then those defaults must be repeated at the higher levels. This is a good reason for not following that principle, because it makes software maintenance more difficult. I don't think I agree with that (though maybe I just didn't get it). I prefer to know what arguments a function is going to use. Another reason for not following that principle is that tf you have several lower level functions with different default values for an argument of the same name, it becomes impossible to get the lower-level default behavior. I'm lost there. When I choose which function to call it has its own default?? I often call a function of mine called timepoints.summary for which I want to pass graphical parameters to boxplots, matplots and confidence interval plots. So I name the arguments cex.boxplot, col.boxplot etc and then within the function I call boxplot(x, cex=boxplot.cex) and so on. I wouldn't expect a single argument cex to magically work out whether it was being used in a boxplot or matplot and change to a different default?? Simon Fear Senior Statistician Syne qua non Ltd Tel: +44 (0) 1379 69 Fax: +44 (0) 1379 65 email: [EMAIL PROTECTED] web: http://www.synequanon.com Number of attachments included with this message: 0 This message (and any associated files) is confidential and\...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] plotting in the same figure
Hello, Do you know if it's possible to create a plot as in matlab with the options hold on and hold off? For example I want to plot in the same figure the theoric cdf of the normal distribution and the empiric cdf from the raw data. Thank you, Josep. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] plotting in the same figure
Look at the argument new under ?par. Probably better way is to use the following sequence: plot(...) # whatever your first plot is. lines(...) # add line to the existing plot. points(...) # add points to the existing plot. There are many other functions that add to the existing plot. HTH, Andy -Original Message- From: Josep Perarnau [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 12:37 PM To: [EMAIL PROTECTED] Subject: [R] plotting in the same figure Hello, Do you know if it's possible to create a plot as in matlab with the options hold on and hold off? For example I want to plot in the same figure the theoric cdf of the normal distribution and the empiric cdf from the raw data. Thank you, Josep. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo /r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Very long console input lines
Have you considered enclosing the very long string in parentheses? Then R will know that it is not syntactically correct until it reaches the end. To avoid that kind of thing, I routinely include ( just to the right of - in virtually any statement that might otherwise get split onto two lines in a way that the first might be evaluated without the second. hope this helps. spencer graves p.s. I got this from Venables and Ripley, but I can't remember which book or which page. [EMAIL PROTECTED] wrote: Hallo all, I got a problem executing R in batch-mode via a perl-script (under Win2000) : system (Rterm.exe --slave --no-save --no-restore \Rfile.r \NUL); The R execution is aborting with syntax error due to very-long lines. My solution is converting a - c(very long string) to a - paste(short string 1,\n short string 2,\n ...,\n short string n) It is not very elegant ... Does anybody know a better solution ? Thank you in advance, Alessandro Valli __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: Just don't do it, surely? (was RE: [R] Retrieve ... argument values)
Simon, I agree, for some (maybe most) arguments it is good to know what defaults are being used. But there are some for which I really don't want to know. An example of the latter is arguments that control interaction with a database. Suppose I have a low-level interaction function that takes an argument 'db.mode', where this specifies a way of interacting with the database. Now, if I also have a higher level function that gets data from the database I might write: db.get.high.level.data - function(what, ...) { processed.what - do something to 'what' db.get.low.level.data(processed.what, ...) } db.get.low.level.data(what, db.mode=2) { # fetch the data } By using ... arguments I can specify a db.mode argument to the higher level function, or just get the default provided in the lower level function. If I then change the lower level function to provide a better mode of interaction I can make that mode the default in the lower level function, and be confident it will be used everywhere. But if I specify the defaults in both places, then changing defaults becomes a big task. As for the second point regarding different functions having different defaults for an argument of the same name, it can certainly be handled as you describe by making different argument names in the higher level function. -- Tony Plate At Wednesday 05:25 PM 9/17/2003 +0100, Simon Fear wrote: Tony, I don't understand what you mean. Could you give an example? -Original Message- From: Tony Plate [mailto:[EMAIL PROTECTED] ... I'm not saying never write functions that use ..., I'm just saying never write functions that depend on a particular argument being passed via Several reasons for not following that principle involve proliferation of defaults -- if the lower level functions have defaults, then those defaults must be repeated at the higher levels. This is a good reason for not following that principle, because it makes software maintenance more difficult. I don't think I agree with that (though maybe I just didn't get it). I prefer to know what arguments a function is going to use. Another reason for not following that principle is that tf you have several lower level functions with different default values for an argument of the same name, it becomes impossible to get the lower-level default behavior. I'm lost there. When I choose which function to call it has its own default?? I often call a function of mine called timepoints.summary for which I want to pass graphical parameters to boxplots, matplots and confidence interval plots. So I name the arguments cex.boxplot, col.boxplot etc and then within the function I call boxplot(x, cex=boxplot.cex) and so on. I wouldn't expect a single argument cex to magically work out whether it was being used in a boxplot or matplot and change to a different default?? Simon Fear Senior Statistician Syne qua non Ltd Tel: +44 (0) 1379 69 Fax: +44 (0) 1379 65 email: [EMAIL PROTECTED] web: http://www.synequanon.com Number of attachments included with this message: 0 This message (and any associated files) is confidential and contains information which may be legally privileged. It is intended for the stated addressee(s) only. Access to this email by anyone else is unauthorised. If you are not the intended addressee, any action taken (or not taken) in reliance on it, or any disclosure or copying of the contents of it is unauthorised and unlawful. If you are not the addressee, please inform the sender immediately and delete the email from your system. This message and any associated attachments have been checked for viruses using an internationally recognised virus detection process. However, Internet communications cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete. Therefore, we do not accept responsibility for any errors or omissions that are present in this message, or any attachment, that have arisen as a result of e-mail transmission. If verification is required, please request a hard-copy version. Any views or opinions presented are solely those of the author and do not necessarily represent those of Syne qua non. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Re: mgcv 0.9 install
It works for me. The last link command is: gcc -shared -L/usr/local/lib -o mgcv.so gcv.o magic.o mat.o matrix.o mgcv.o qp.o tprs.o -llapack -lblas ... I have NOT got libf77blas in my linux system either but I have got libblas.a and libblas.so and the linker find the right library libblas to link. Pingping Simon Wood wrote: /usr/bin/ld: cannot find -lf77blas - this is the problem, the linker can't find the basic linear algebra system library on your machine (I'm surprised R can be built without this). I think you may need to install the atlas package, but am not sure: hopefully someone else will know... Simon __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] 3D plot/surface rotation
Another possibility (to plug my own stuff) is to use the LG3d package in my bbmisc package (http://www.zoo.ufl.edu/bolker/R/src for source, http://www.zoo.ufl.edu/bolker/R/windows/ for precompiled windows package), which uses the Live3D java applet to display (rotatable etc.) graphics in a web browser. Not as good as x/ggobi for interaction with data, but possibly OK for display. Ben Bolker On Wed, 17 Sep 2003, Brian D Ripley wrote: On Wed, 17 Sep 2003, Thomas W Blackwell wrote: Perhaps MZodet wants the interactive, mouse controlled rotation capability offered by ggobi www.ggobi.org ? Designed for linux but advertises better portability to Microsoft Windows. I have no experience myself either installing or using this. It doesn't cover surfaces AFAIK. There are R-GL packages which do allow user-controlled rotations of surfaces (and more). Another possibility is to write some widget (e.g. in Tcl/Tk) to control the screen argument, and replot when the argument is changed (as the tkdensity demo does). Under Windows, the latter works a lot better in 1.8.0 alpha which has buffering. - tom blackwell - u michigan medical school - ann arbor - Wednesday, September 17, 2003, 2:14:12 PM, MZodet wrote: How do I rotate 3D plots/surfaces generated by either cloud or wireframe? On Wed, 17 Sep 2003, Mark Marques wrote: wireframe has the screen parameter which reads a list to rotate ... something in this kind: wireframe(object, screen = list( x = 5, y = 5 , z= 10)) Same with cloud function... __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- 620B Bartram Hall[EMAIL PROTECTED] Zoology Department, University of Floridahttp://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Transpose Data Frame Question
Hi, I have a data.frame that has 3 columns (ID, Test, Result) and looks like this 1, Test1, 120 1, Test2, 34 2, Test1, 132 2, Test2, 28 etc I would like to turn it around so that it looks like this 1, 120, 34 2, 132, 28 etc I have played around some with t and reshape, but with no success. Any suggestions or hints would be greatly appreciated. Thanks, Bruce - [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R]Bivariate Ripley K function
Roger D. Peng wrote: I believe the `splancs' package from CRAN has a bivariate K function. For error bars you'll probably have to use Monte Carlo methods. `splancs' has some tools for that. See also 'spatstat' for Kmulti and Kcross. Since R doesn't have a univariate K-function in the base or recommended packages I'm wondering which package the original poster got univariate K-function from. I suspect their friendly sysop installed splancs or spatstat. Baz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Transpose Data Frame Question
Here is a brute force way: mm - NULL for(i in unique(ID)){ zz - data.frame[ID==i, 3] mm - rbind(mm, c(i, zz)) } It will work as long as you have the same number of tests for each ID. If not, you would need to pad shorter zz vectors with NAs. Cheers, Andy __ Andy Jaworski Engineering Systems Technology Center 3M Center, 518-1-01 St. Paul, MN 55144-1000 - E-mail: [EMAIL PROTECTED] Tel: (651) 733-6092 Fax: (651) 736-3122 |-+ | | Bruce Coate | | | [EMAIL PROTECTED]| | | m | | | Sent by: | | | [EMAIL PROTECTED]| | | ath.ethz.ch | | || | || | | 09/17/2003 12:30 | | || |-+ -| | | | To: [EMAIL PROTECTED] | | cc: | | Subject: [R] Transpose Data Frame Question | -| Hi, I have a data.frame that has 3 columns (ID, Test, Result) and looks like this 1, Test1, 120 1, Test2, 34 2, Test1, 132 2, Test2, 28 etc I would like to turn it around so that it looks like this 1, 120, 34 2, 132, 28 etc I have played around some with t and reshape, but with no success. Any suggestions or hints would be greatly appreciated. Thanks, Bruce - [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] using matrix data for function
Hi All, I have a function, f(x,y) I have a matrix of data, m, with the 1st column is x and the 2nd column is y What's the best way to get f(x,y) for each row of the matrix? I tried result-f(m[,1],m[,2]) but it doesn't work. Thanks! Bing - 1060 Commerce Park Oak Ridge National Laboratory P.O. Box 2008, MS 6480 Oak Ridge, TN 37831-6480 Phone: 865-241-0761 Email: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Transpose Data Frame Question
Isn't this what you want? x - data.frame(id=rep(1:2, each=2), test = rep(c(test1,test2), 2), + score = c(120, 34, 132, 28)) x id test score 1 1 test1 120 2 1 test234 3 2 test1 132 4 2 test228 reshape(x, timevar=test, direction=wide) id score.test1 score.test2 1 1 120 34 3 2 132 28 HTH, Andy -Original Message- From: Bruce Coate [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 1:30 PM To: [EMAIL PROTECTED] Subject: [R] Transpose Data Frame Question Hi, I have a data.frame that has 3 columns (ID, Test, Result) and looks like this 1, Test1, 120 1, Test2, 34 2, Test1, 132 2, Test2, 28 etc I would like to turn it around so that it looks like this 1, 120, 34 2, 132, 28 etc I have played around some with t and reshape, but with no success. Any suggestions or hints would be greatly appreciated. Thanks, Bruce - [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo /r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
AW: [R] using matrix data for function
I'm not sure if that's the best way apply(MAT, 1, FUN) -Ursprngliche Nachricht- Von: Bing Zhang [mailto:[EMAIL PROTECTED] Gesendet: Mi 17.09.2003 20:02 An: r-help Cc: Betreff: [R] using matrix data for function Hi All, I have a function, f(x,y) I have a matrix of data, m, with the 1st column is x and the 2nd column is y What's the best way to get f(x,y) for each row of the matrix? I tried result-f(m[,1],m[,2]) but it doesn't work. Thanks! Bing - 1060 Commerce Park Oak Ridge National Laboratory P.O. Box 2008, MS 6480 Oak Ridge, TN 37831-6480 Phone: 865-241-0761 Email: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] the name of a variable in a function
Dear collegues, How can I get the name of a variable (and not the variable) within a function ? For instance, in the following function, I'd like to create a variable in the dataframe df with the same name to the variable passed in var: prova - function( var ) { df - as.data.frame(matrix(nr=20,nc=0)) df[[here]] - seq(min(var), max(var), le= 20) # df } for instance, a - 1:50 prova(a) should give a dataframe with a variable called a (df$a) Thanks in advance Juli __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] using matrix data for function
Thanks. How about I have a third parameter for the function, which is a fixed object? i.e. the function is f(o,x,y) Bing = Original Message From [EMAIL PROTECTED] = Assuming that f(x,y) is not vectorize, try apply(your.matrix, 1, function(x) f(x[1], x[2])) as in: x.1 - matrix(1:12,ncol=2) x.1 [,1] [,2] [1,]17 [2,]28 [3,]39 [4,]4 10 [5,]5 11 [6,]6 12 x.f - function(x,y) x+y apply(x.1, 1, function(x) x.f(x[1], x[2])) [1] 8 10 12 14 16 18 __ James HoltmanWhat is the problem you are trying to solve? Executive Consultant -- Office of Technology, Convergys [EMAIL PROTECTED] (513) 723-2929 Bing Zhang [EMAIL PROTECTED] To: r-help [EMAIL PROTECTED] Sent by: cc: [EMAIL PROTECTED]Subject: [R] using matrix data for function ath.ethz.ch 09/17/2003 14:02 Hi All, I have a function, f(x,y) I have a matrix of data, m, with the 1st column is x and the 2nd column is y What's the best way to get f(x,y) for each row of the matrix? I tried result-f(m[,1],m[,2]) but it doesn't work. Thanks! Bing - 1060 Commerce Park Oak Ridge National Laboratory P.O. Box 2008, MS 6480 Oak Ridge, TN 37831-6480 Phone: 865-241-0761 Email: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- NOTICE: The information contained in this electronic mail transmission is intended by Convergys Corporation for the use of the named individual or entity to which it is directed and may contain information that is privileged or otherwise confidential. If you have received this electronic mail transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply email or by telephone (collect), so that the sender's address records can be corrected. - 1060 Commerce Park Oak Ridge National Laboratory P.O. Box 2008, MS 6480 Oak Ridge, TN 37831-6480 Phone: 865-241-0761 Email: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] using matrix data for function
Don't think this is best, but here's one way: mat - matrix(1:12, 6) mat [,1] [,2] [1,]17 [2,]28 [3,]39 [4,]4 10 [5,]5 11 [6,]6 12 f - function(x, y) x + y apply(mat, 1, function(x) do.call(f, as.list(x))) [1] 8 10 12 14 16 18 Note that apply(mat, 1, f) won't work, because both values are passed to f in a single vector. Perhaps better alternatives are: 1. Re-write f so that it takes a single vector of two elements, or write a wrapper fw - function(x) f(x[1], x[2]), then use fw in apply(). 2. Re-write f so that it's vectorized, so that f(mat[,1], fmat[,2]) works. HTH, Andy -Original Message- From: Bing Zhang [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 2:03 PM To: r-help Subject: [R] using matrix data for function Hi All, I have a function, f(x,y) I have a matrix of data, m, with the 1st column is x and the 2nd column is y What's the best way to get f(x,y) for each row of the matrix? I tried result-f(m[,1],m[,2]) but it doesn't work. Thanks! Bing - 1060 Commerce Park Oak Ridge National Laboratory P.O. Box 2008, MS 6480 Oak Ridge, TN 37831-6480 Phone: 865-241-0761 Email: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo /r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] the name of a variable in a function
Well you don't know that the actual argument to a function is a name - it could be a more complex expression. In any case, you can get the expression that was the actual argument with the substitute function, then you need to deparse it. Your function could be written prova - function( var ) + { + df - data.frame(seq(min(var), max(var), len = 20)) + names(df) - deparse(substitute(var)) + df + } prova(a) a 1 1.00 2 3.578947 3 6.157895 4 8.736842 5 11.315789 6 13.894737 7 16.473684 8 19.052632 9 21.631579 10 24.210526 11 26.789474 12 29.368421 13 31.947368 14 34.526316 15 37.105263 16 39.684211 17 42.263158 18 44.842105 19 47.421053 20 50.00 juli g. pausas [EMAIL PROTECTED] writes: Dear collegues, How can I get the name of a variable (and not the variable) within a function ? For instance, in the following function, I'd like to create a variable in the dataframe df with the same name to the variable passed in var: prova - function( var ) { df - as.data.frame(matrix(nr=20,nc=0)) df[[here]] - seq(min(var), max(var), le= 20) # df } for instance, a - 1:50 prova(a) should give a dataframe with a variable called a (df$a) Thanks in advance Juli __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- Douglas Bates[EMAIL PROTECTED] Statistics Department608/262-2598 University of Wisconsin - Madisonhttp://www.stat.wisc.edu/~bates/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] CART analysis
Greetings, Does anyone know of an R code for classification and regression tree analysis (CART)? Thank you Ron Ron Thornton BVSc, PhD, MACVSc (pathology, epidemiology) Programme Co-ordinator, Active Surveillance Animal Biosecurity MAF Biosecurity Authority P O Box 2526 Wellington, New Zealand phone: 64-4-4744156 027 223 7582 fax: 64-4-474-4133 e-mail: [EMAIL PROTECTED] http://www.maf.govt.nz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] CART analysis
Ron, Does anyone know of an R code for classification and regression tree analysis (CART)? If I got you right, you need a tree package. It implemets the CART method. If you go further, you will like randomForest package. Regards, Vladimir __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Using POSIX?t rather than chron or date
The problem with POSIXt is that you must consider timezones and daylight vs. standard time issues even if you don't want to. This violates modularity (viz. your routines becomes coupled to unrelated information) and leads to subtle errors where different routines are assuming different time zones. The problem is that the time, date, day of the week, month, etc. of a date depend on its time zone so even if you are just concerned with daily data in a fixed time zone, say, you are still dragged into time zone and standard vs. daylight considerations. I recently converted a program using POSIXt to chron and it allowed me to eliminate all the tz parameters that I was passing around and even better it meant I did not even have to THINK about time zones and all the associated headaches they were giving me. I had previously suggested that we either put chron into the base or create a new timezone-less version of POSIXt to complement what is already in the base. See: https://stat.ethz.ch/pipermail/r-devel/2003-August/027269.html --- Martin Maechler [EMAIL PROTECTED] wrote: BDR == Prof Brian Ripley [EMAIL PROTECTED] on Wed, 17 Sep 2003 06:58:48 +0100 (BST) writes: BDR On Tue, 16 Sep 2003, Deepayan Sarkar wrote: Is the date class standard enough to warrant including a check for it in lattice ? BDR I don't think so. The POSIX*t classes in R are the BDR most standard, followed by the chron package and only BDR then the date package. Definitely. And I think we should encourage people to upgrade to POSIX.t from chron (let alone date) more strongly {Note that there have been as.POSIXct() methods for these classes since the beginning of the POSIX.t classes. Could chron and date users be heard about what functionality they are missing in POSIX.t ? On the other hand, the recommended package survival has a(nother?) class date and that package is based on S(plus) code and may hence not be convertible sensibly ? Martin Maechler [EMAIL PROTECTED] http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] CART analysis
library(tree) ?tree should work. If you don't have the tree library, you can download it off of CRAN at http://cran.r-project.org/bin/windows/contrib if you're using Windows, or go to http://cran.r-project.org/src/contrib/PACKAGES.html for the source code directly as gzipped .tar files. I'm not all that familiar with Linux or the RPM files that are used to install R on the various Linux flavors... having said that, my understanding is that you would compile the packages from their source code directly if you are using R on a Linux operating system. Best wishes, david paul -Original Message- From: Ron Thornton [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 3:51 PM To: [EMAIL PROTECTED] Subject: [R] CART analysis Greetings, Does anyone know of an R code for classification and regression tree analysis (CART)? Thank you Ron Ron Thornton BVSc, PhD, MACVSc (pathology, epidemiology) Programme Co-ordinator, Active Surveillance Animal Biosecurity MAF Biosecurity Authority P O Box 2526 Wellington, New Zealand phone: 64-4-4744156 027 223 7582 fax: 64-4-474-4133 e-mail: [EMAIL PROTECTED] http://www.maf.govt.nz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] CART analysis
Or, I think, the rpart package. On Thu, 18 Sep 2003, Vladimir N. Kutinsky wrote: Date: Thu, 18 Sep 2003 00:18:25 +0400 From: Vladimir N. Kutinsky [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: RE: [R] CART analysis Ron, Does anyone know of an R code for classification and regression tree analysis (CART)? If I got you right, you need a tree package. It implemets the CART method. If you go further, you will like randomForest package. Regards, Vladimir __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- Cheers, Kevin -- On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question. -- Charles Babbage (1791-1871) From Computer Stupidities: http://rinkworks.com/stupid/ -- Ko-Kang Kevin Wang Master of Science (MSc) Student SLC Tutor and Lab Demonstrator Department of Statistics University of Auckland New Zealand Homepage: http://www.stat.auckland.ac.nz/~kwan022 Ph: 373-7599 x88475 (City) x88480 (Tamaki) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] using matrix data for function
On Thu, 2003-09-18 at 06:02, Bing Zhang wrote: Hi All, I have a function, f(x,y) I have a matrix of data, m, with the 1st column is x and the 2nd column is y What's the best way to get f(x,y) for each row of the matrix? I tried result-f(m[,1],m[,2]) but it doesn't work. That is the best way, provided your function handles vectors nicely. Apparently, yours doesn't. Next best is something like apply(m,2,f) Cheers Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz +64-(0)21-343-545 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] using matrix data for function
On Thu, 2003-09-18 at 06:41, Bing Zhang wrote: Thanks. How about I have a third parameter for the function, which is a fixed object? i.e. the function is f(o,x,y) 1) My earlier reply had a typo. Should've been apply(m,1,f). 2) Luckily, the answer to this question, and any more you're likely to have about apply(), are documented quite nicly. help(apply) Cheers Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz +64-(0)21-343-545 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Using POSIX?t rather than chron or date
On Wed, 2003-09-17 at 19:03, Gabor Grothendieck wrote: The problem with POSIXt is that you must consider timezones and daylight vs. standard time issues even if you don't want to. ... I had previously suggested that we either put chron into the base or create a new timezone-less version of POSIXt to complement what is already in the base. See: When I don't want to be bothered with time zones, DST, etc, I set all time zones to UTC. Works fine for me. I'd love to say I thought of it myself, but it's an old trick frequently used in industrial real-time control systems that have daylight savings features when they're not welcome. Cheers Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz +64-(0)21-343-545 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Using POSIX?t rather than chron or date
The problem with using a convention is that you can't be guaranteed that all the routines you use also use that same convention. You still have to understand how each of the routines you use handle time zones and you are dragged into thinking about an irrelevant piece of information violating modularity and making your code more error prone. (I think I made some of these points already but I thought they bear repeating in light of this discussion.) Essentially the POSIXt0 classes discussed in the link in my previous posting do what you are suggesting internally but use the class mechanism to enforce it. Chron also has no timezone so does not have the problems of POSIXt in this regard. --- Jason Turner [EMAIL PROTECTED] wrote: On Wed, 2003-09-17 at 19:03, Gabor Grothendieck wrote: The problem with POSIXt is that you must consider timezones and daylight vs. standard time issues even if you don't want to. ... I had previously suggested that we either put chron into the base or create a new timezone-less version of POSIXt to complement what is already in the base. See: When I don't want to be bothered with time zones, DST, etc, I set all time zones to UTC. Works fine for me. I'd love to say I thought of it myself, but it's an old trick frequently used in industrial real-time control systems that have daylight savings features when they're not welcome. Cheers Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz +64-(0)21-343-545 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Building and loading a DLL on Windows NT
Thanks. I didn't try the Borland utility but your response reminded me of a way to view the DLL info in Windows. Right click a DLL and then quick view and Windows outputs some file information, including the Export table which lists the names of the symbols in the DLL. The name of the add function is _Z3addPdS_. So it works now. Thanks for your help. Ben Stabler Oregon Department of Transportation -Original Message- From: Whit Armstrong [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 1:56 PM To: STABLER Benjamin Subject: RE: [R] Building and loading a DLL on Windows NT There's a free utility from borland (I think it's called tdump or dump) that will show you all the exports from a dll. You could run that on the dll you made to see what name the function is being exported under (sorry, but I don't have the link). Other than that, it looks like you're doing everything right. I've never built a DLL using SHLIB, so I can't help you there. Good luck, Whit -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 4:52 PM To: [EMAIL PROTECTED] Subject: [R] Building and loading a DLL on Windows NT I am trying to build a simple dll with Rcmd SHLIB to link into R. The results of the build are below. From my limited knowledge of building DLLs, it looks like it worked (I didn't get any errors). F:\R\dlls Rcmd SHLIB add.C making add.d from add.C g++ -IC:/PROGRA~1/R/src/include -Wall -O2 -c add.C -o add.o ar cr add.a *.o ranlib add.a g++ --shared -s -o add.dll add.def add.a -LC:/PROGRA~1/R/src/gnuwin32 -lg2c -lR Then I tried to load the DLL into R with: dyn.load(F:\\R\\dlls\\add.dll) which returned nothing (which I assumes means there were no errors). But, is.loaded(symbol.C(add)) [1] FALSE returns false. add is the name of the function in the source file. I know I can dynamically load other DLLs. I've read quite a bit of documentation and I am still stumped. I have all the proper tools for building R under Windows and I know they work since I have built Windows package binaries. Any ideas on what I am doing wrong would be greatly appreciated. Thanks. Ben Stabler __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Building XML library on MacOS X
This is not a strictly R question, but I am trying to build the XML package on MacOS X and have not been successful. I have tried using expat, libxml, and libxml2 without success in building. Has someone successfully done this that could enlighten me with the process (especially as it relates to installing a libxml version and then completing the XML package installation, specifying the correct environment variables, etc.)? Thanks in advance, Sean __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] all possible samples
On 17-Sep-03 lamack lamack wrote: Dear all, there is an R function that return all possible samples of size n, with replacement, from a vector of length N ? Without delving into R to see if such a thing exists already, I can suggest the following (based on an algorithm to be found in Nijenhuis and Wilf, Combinatorial Algortithms, Academic Press 1978). I once implemented it in octave and it worked well. I'll use their notation rather than yours so that I don't confuse my fingers ... To select all subsets of size k out of n (in lexicographic order): The n-set is {1,2,3,...,n}. A selected subset is {a[1],a[2],...,a[k]}. Repeatedly apply the following algorithm for next subset: (A) If first time (first subset): m-0; h-k; go to (D) (B) If not first time: if( m=n-h ) go to (C); else h-0; (C) h-(h+1); m-a[k+1-h]; (D) for(j in (1:h)) {a[k+j-h]-(m+j)}; if( a[1]==(n-k+1)) final_exit (all done); else nonfinal_exit (some left); For 3 out of 5 this gives {1,2,3},(1,2,4},{1,2,5},{1,3,4},{1,3,5}, {1,4,5},{2,3,4},{2,3,5},{2,4,5},{3,4,5}. Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 167 1972 Date: 17-Sep-03 Time: 20:21:32 -- XFMail -- __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] RE: all possible samples
Hi, Another possibility is to use the combinations function in the gregmisc package, which has an option repeats.allowed. Sorry for not including the original post, but I had deleted it from my mailbox earlier in the day. HTH, Dennis __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] subsetting matrix replacement oddities
When assigning a dataframe to a subset of a matrix I got a very odd result. Am I missing something, or is this a bug? Details are below. Also, if m is defined outside of the current function, is m[...] - foo necessary to update it, or does regular replacement m[] - foo work (that is, does it update the global rather than creating a local that conceals it)? I got conflicting results, which were tangled up with the oddity below. Browse[1] covs epilepsy other.cancer 68000 68100 68200 68301 68400 Browse[1] m - matrix(NA, 5,2) Browse[1] m[,1:2] - covs Browse[1] m [[1]] [1] 0 0 0 0 0 [[2]] [1] 0 0 0 1 0 [[3]] [1] 0 0 0 0 0 [[4]] [1] 0 0 0 1 0 [[5]] [1] 0 0 0 0 0 [[6]] [1] 0 0 0 1 0 [[7]] [1] 0 0 0 0 0 [[8]] [1] 0 0 0 1 0 [[9]] [1] 0 0 0 0 0 [[10]] [1] 0 0 0 1 0 Browse[1] dim(covs) [1] 5 2 Browse[1] class(covs) [1] data.frame Browse[1] class(m) [1] list Browse[1] length(m) [1] 10 Fortunately, the following seems to work as expected: Browse[1] m[,1:2] - as.matrix(covs) Ross Boylan wk: (415) 502-4031 530 Parnassus Avenue (Library) rm 115-4 [EMAIL PROTECTED] Dept of Epidemiology and Biostatistics fax: (415) 476-9856 University of California, San Francisco San Francisco, CA 94143-0840 hm: (415) 550-1062 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] subsetting matrix replacement oddities
A subset of a data.frame is still a data.frame. A data.frame is actually a list with additional attributes. As far as I know, your solution, as.matrix, is an appropriate tool to convert a data.frame to a matrix. Caution may be appropropriate, however, because if the data.frame includes anything not numeric, the result may not be numeric, and the result is inconsistent between S-Plus 6.1 and R 1.7.1. Consider the following: S-PLUS 6.1: DF - data.frame(a = 1:2, b = letters[1:2]) DF2 - data.frame(c = TRUE) DF3 - data.frame(c = TRUE, d = 2) sapply(DF, class) ab integer factor as.matrix(DF) a b 1 1 a 2 2 b as.matrix(DF2) c 1 T as.matrix(DF3) c d 1 1 2 ## R 1.7.1: DF - data.frame(a=1:2, b=letters[1:2]) DF2 - data.frame(c=TRUE) DF3 - data.frame(c=TRUE, d=2) sapply(DF, class) a b integer factor as.matrix(DF) a b 1 1 a 2 2 b as.matrix(DF2) c 1 TRUE as.matrix(DF3) c d 1 TRUE 2 # Hope this helps. spencer graves Ross Boylan wrote: When assigning a dataframe to a subset of a matrix I got a very odd result. Am I missing something, or is this a bug? Details are below. Also, if m is defined outside of the current function, is m[...] - foo necessary to update it, or does regular replacement m[] - foo work (that is, does it update the global rather than creating a local that conceals it)? I got conflicting results, which were tangled up with the oddity below. Browse[1] covs epilepsy other.cancer 68000 68100 68200 68301 68400 Browse[1] m - matrix(NA, 5,2) Browse[1] m[,1:2] - covs Browse[1] m [[1]] [1] 0 0 0 0 0 [[2]] [1] 0 0 0 1 0 [[3]] [1] 0 0 0 0 0 [[4]] [1] 0 0 0 1 0 [[5]] [1] 0 0 0 0 0 [[6]] [1] 0 0 0 1 0 [[7]] [1] 0 0 0 0 0 [[8]] [1] 0 0 0 1 0 [[9]] [1] 0 0 0 0 0 [[10]] [1] 0 0 0 1 0 Browse[1] dim(covs) [1] 5 2 Browse[1] class(covs) [1] data.frame Browse[1] class(m) [1] list Browse[1] length(m) [1] 10 Fortunately, the following seems to work as expected: Browse[1] m[,1:2] - as.matrix(covs) Ross Boylan wk: (415) 502-4031 530 Parnassus Avenue (Library) rm 115-4 [EMAIL PROTECTED] Dept of Epidemiology and Biostatistics fax: (415) 476-9856 University of California, San Francisco San Francisco, CA 94143-0840 hm: (415) 550-1062 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Suming logical vectors
Can anyone explain the following? [R 1.6.0 Windows XP, yes I will upgrade soon.] Murray sort(IATmedian)[0:50]==0 [1] TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [49] FALSE FALSE sum(sort(IATmedian)[0:50]==0) [1] 2 sum(sort(IATmedian)==0) [1] 2 sum(IATmedian==0) [1] NA -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wk+64 7 849 6486 homeMobile 021 1395 862 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Suming logical vectors
Your IATmedian has some NAs (which are removed by sort) ? On Thu, 18 Sep 2003, Murray Jorgensen wrote: Can anyone explain the following? [R 1.6.0 Windows XP, yes I will upgrade soon.] Murray sort(IATmedian)[0:50]==0 [1] TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [49] FALSE FALSE sum(sort(IATmedian)[0:50]==0) [1] 2 sum(sort(IATmedian)==0) [1] 2 sum(IATmedian==0) [1] NA -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wk+64 7 849 6486 homeMobile 021 1395 862 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Suming logical vectors
Blush! Not too hard to explain at all! Deepayan Sarkar wrote: Your IATmedian has some NAs (which are removed by sort) ? On Thu, 18 Sep 2003, Murray Jorgensen wrote: Can anyone explain the following? [R 1.6.0 Windows XP, yes I will upgrade soon.] Murray sort(IATmedian)[0:50]==0 [1] TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [49] FALSE FALSE sum(sort(IATmedian)[0:50]==0) [1] 2 sum(sort(IATmedian)==0) [1] 2 sum(IATmedian==0) [1] NA -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wk+64 7 849 6486 homeMobile 021 1395 862 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wk+64 7 849 6486 homeMobile 021 1395 862 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Date on x-axis of xyplot
[Due to problems with my mail client, this message may eventually reach the list twice. Sorry about that.] On Wednesday 17 September 2003 08:51, David James wrote: Prof Brian Ripley wrote: On Tue, 16 Sep 2003, Deepayan Sarkar wrote: Is the date class standard enough to warrant including a check for it in lattice ? I don't think so. The POSIX*t classes in R are the most standard, followed by the chron package and only then the date package. If it is not overly complicated to implement, could I timidly suggest *not* checking for specific classes inside lattice, but rather use some other kind of mechanism (perhaps invoking helper functions, or use specific methods, etc.) to render axes? This is definitely a good idea generally, and lattice tries to do that as much as possible (exceptions being splom, cloud, wireframe). However, at some point the tick locations and labels need to be calculated by some variation of pretty and format, which loses the class attribute and has to be processed case by case. In fact for POSIXct, pretty doesn't return sensible values, and that case has to be handled completely separately. The base plot functions seem to handle this via axis.POSIXct, which is not directly usable and so is essentially repeated in lattice. It might be a good idea to eventually separate the common part out as something similar to pretty. I also just dicovered that POSIXct handling in lattice is broken, except when scales$relation = free or sliced. I'll fix this ASAP. Deepayan __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] print graph
Hello. I am using R 1.7.1 on Mac OSX10.2.6 and XDarwin86 4.3. I made barplot graph by barplot2. I can get good graph on x11() device. But when change the device to potscript(), the graph changed to incomplete. For example, absence of label or err bar or ... I would like to print out this graph. Can anyone suggest how to print out graph? Hope this help, Thank you, atuya __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] print graph
On Wed, 2003-09-17 at 21:56, Atsuya Fujito wrote: Hello. I am using R 1.7.1 on Mac OSX10.2.6 and XDarwin86 4.3. I made barplot graph by barplot2. I can get good graph on x11() device. But when change the device to potscript(), the graph changed to incomplete. For example, absence of label or err bar or ... I would like to print out this graph. Can anyone suggest how to print out graph? Hope this help, Thank you, atuya Did you remember to use: dev.off() after completing the plot? For example: postscript(barplot2.ps) barplot2(1:10) dev.off() HTH, Marc Schwartz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help