[Rd] S3 best practice

2007-03-02 Thread Robin Hankin
Hello everyone Suppose I have an S3 class "dog" and a function plot.dog() which looks like this: plot.dog <- function(x,show.uncertainty, ...){ if (show.uncertainty){ } } I think that it would be better to somehow precalculate the uncertainty stuff and plot it separately. How b

[Rd] Install.packages() bug in Windows XP (PR#9540)

2007-03-02 Thread juan
Dear User=B4s, =20 run R2.2.0 for Windows Version (S.O. Windows XP) when install.packages() function, after select the mirror, shown: --- Please select a CRAN mirror for use in this session --- Aviso: unable to access index for repository http://cran.br.r-project.org/bin/windows/contrib/2.2 Aviso:

Re: [Rd] Install.packages() bug in Windows XP (PR#9540)

2007-03-02 Thread Uwe Ligges
This is not a bug. And if a bug, you are asked to only report bugs of recent versions of R! Please ask questions on R-help! 1. Please check your firewall and proxy settings. 2. Please upgrade to a recent version of R. Uwe Ligges [EMAIL PROTECTED] wrote: > Dear User=B4s, > =20 > run R2.2.0 for

Re: [Rd] S3 best practice

2007-03-02 Thread Seth Falcon
Robin Hankin <[EMAIL PROTECTED]> writes: > Hello everyone > > Suppose I have an S3 class "dog" and a function plot.dog() which > looks like this: > > plot.dog <- function(x,show.uncertainty, ...){ > >if (show.uncertainty){ >and superimpose the results on the simple plot> >

[Rd] Wishlist: Make screeplot() a generic (PR#9541)

2007-03-02 Thread gavin . simpson
Full_Name: Gavin Simpson Version: 2.5.0 OS: Linux (FC5) Submission from: (NULL) (128.40.33.76) Screeplots are a common plot-type used to interpret the results of various ordination methods and other techniques. A number of packages include ordination techniques not included in a standard R instal

[Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-02 Thread Herve Pages
Hi, I have a big data frame: > mat <- matrix(rep(paste(letters, collapse=""), 5*30), ncol=5) > dat <- as.data.frame(mat) and I need to do some computation on each row. Currently I'm doing this: > for (key in row.names(dat)) { row <- dat[key, ]; ... do some computation on row... } w

Re: [Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-02 Thread Herve Pages
Herve Pages wrote: ... > But if, instead of the above, I do this: > > > for (i in nrow(dat)) { row <- sapply(dat, function(col) col[i]) } Should have been: > for (i in 1:nrow(dat)) { row <- sapply(dat, function(col) col[i]) } > > then it's 20 times faster!! > > > system.time(for (i in 1

Re: [Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-02 Thread Roger D. Peng
Extracting rows from data frames is tricky, since each of the columns could be of a different class. For your toy example, it seems a matrix would be a more reasonable option. R-devel has some improvements to row extraction, if I remember correctly. You might want to try your example there.

Re: [Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-02 Thread Greg Snow
Your 2 examples have 2 differences and they are therefore confounded in their effects. What are your results for: system.time(for (i in 1:100) {row <- dat[i, ] }) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -Ori

Re: [Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-02 Thread Wolfgang Huber
Hi Hervé depending on your problem, using "mapply" might help, as in the code example below: a = data.frame(matrix(1:3e4, ncol=3)) print(system.time({ r1 = numeric(nrow(a)) for(i in seq_len(nrow(a))) { g = a[i,] r1[i] = mean(c(g$X1, g$X2, g$X3)) }})) print(system.time({ f = function(X1,

[Rd] Patch for format.pval limitation in format.R

2007-03-02 Thread Charles Dupont
'format.pval' has a major limitation in its implementation for example suppose a person had a vector like 'a' and the error being ±0.001. > a <- c(0.1, 0.3, 0.4, 0.5, 0.3, 0.0001) > format.pval(a, eps=0.001) The person wants to have the 'format.pval' output with 2 digits always showing l

Re: [Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-02 Thread Herve Pages
Roger D. Peng wrote: > Extracting rows from data frames is tricky, since each of the columns > could be of a different class. For your toy example, it seems a matrix > would be a more reasonable option. There is no doubt about this ;-) > mat <- matrix(rep(paste(letters, collapse=""), 5*30)

Re: [Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-02 Thread Ulf Martin
Here is an even faster one; the general point is to create a properly vectorized custom function/expression: mymean <- function(x, y, z) (x+y+z)/3 a = data.frame(matrix(1:3e4, ncol=3)) attach(a) print(system.time({r3 = mymean(X1,X2,X3)})) detach(a) # Yields: # [1] 0.000 0.010 0.005 0.000 0.000

Re: [Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-02 Thread Herve Pages
Ulf Martin wrote: > Here is an even faster one; the general point is to create a properly > vectorized custom function/expression: > > mymean <- function(x, y, z) (x+y+z)/3 > > a = data.frame(matrix(1:3e4, ncol=3)) > attach(a) > print(system.time({r3 = mymean(X1,X2,X3)})) > detach(a) > > # Yield

Re: [Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-02 Thread Herve Pages
Hi Wolfgang, Wolfgang Huber wrote: > > Hi Hervé > > depending on your problem, using "mapply" might help, as in the code > example below: > > a = data.frame(matrix(1:3e4, ncol=3)) > > print(system.time({ > r1 = numeric(nrow(a)) > for(i in seq_len(nrow(a))) { > g = a[i,] > r1[i] = mean(c(g

Re: [Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-02 Thread Herve Pages
Hi Greg, Greg Snow wrote: > Your 2 examples have 2 differences and they are therefore confounded in > their effects. > > What are your results for: > > system.time(for (i in 1:100) {row <- dat[i, ] }) > > > Right. What you suggest is even faster (and more simple): > mat <- matrix(rep(pas

Re: [Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-02 Thread Seth Falcon
Herve Pages <[EMAIL PROTECTED]> writes: > So apparently here extracting with dat[i, ] is 300 times faster than > extracting with dat[key, ] ! > >> system.time(for (i in 1:100) dat["1", ]) >user system elapsed > 12.680 0.396 13.075 > >> system.time(for (i in 1:100) dat[1, ]) >user syst