Re: [Rd] reshape scaling with large numbers of times/rows

2006-08-24 Thread Gabor Grothendieck
If for each combination of X and Y there is at most one Z and Z is numeric (it could be made so in your example) then you could use xtabs which is faster: > m <- n <- 10 > DF <- data.frame(X = gl(m*n, 1), Y = gl(m, n), Z = 10*(1:(n*m))) > system.time(w1 <- reshape(DF, timevar = "X", idvar = "Y", d

Re: [Rd] reshape scaling with large numbers of times/rows

2006-08-24 Thread Mitchell Skinner
I wrote: > It still needs some debugging, to put it mildly > (doesn't work properly on reals), but the basic idea appears to work. It works for reals on a 64-bit machine, but not on a 32-bit machine. I figure the culprit is this bit of c code: SET_VECTOR_ELT(wideCol, wideRow, VECTOR_ELT(longCol,

Re: [Rd] reshape scaling with large numbers of times/rows

2006-08-24 Thread Martin Maechler
> "Mitchell" == Mitchell Skinner <[EMAIL PROTECTED]> > on Thu, 24 Aug 2006 00:26:52 -0700 writes: Mitchell> I wrote: >> It still needs some debugging, to put it mildly >> (doesn't work properly on reals), but the basic idea appears to work. Mitchell> It works for reals

Re: [Rd] reshape scaling with large numbers of times/rows

2006-08-24 Thread Prof Brian Ripley
On Thu, 24 Aug 2006, Martin Maechler wrote: > > "Mitchell" == Mitchell Skinner <[EMAIL PROTECTED]> > > on Thu, 24 Aug 2006 00:26:52 -0700 writes: > > Mitchell> I wrote: > >> It still needs some debugging, to put it mildly > >> (doesn't work properly on reals), but the basi

Re: [Rd] reshape scaling with large numbers of times/rows

2006-08-24 Thread Prof Brian Ripley
Your example does not correspond to your description. You have taken a random number of loci for each subject and measured each a random number of times: > with(test, table(table(subject, locus))) 0 1 2 3 4 5 6 7 8 118021 114340 54963 17848 4288

Re: [Rd] reshape scaling with large numbers of times/rows

2006-08-24 Thread Mitch Skinner
I'd like to thank everyone that's replied so far--more inline: On Thu, 2006-08-24 at 11:16 +0100, Prof Brian Ripley wrote: > Your example does not correspond to your description. You have taken a > random number of loci for each subject and measured each a random number > of times: You're righ

Re: [Rd] reshape scaling with large numbers of times/rows

2006-08-24 Thread Gabor Grothendieck
If your Z in reality is not naturally numeric try representing it as a factor and using the numeric levels as your numbers and then put the level labels back on: m <- n <- 5 DF <- data.frame(X = gl(m*n, 1), Y = gl(m, n), Z = letters[1:25]) Zn <- as.numeric(DF$Z) system.time(w1 <- reshape(DF, timev

Re: [Rd] reshape scaling with large numbers of times/rows

2006-08-24 Thread Mitch Skinner
On Thu, 2006-08-24 at 08:57 -0400, Gabor Grothendieck wrote: > If your Z in reality is not naturally numeric try representing it as a > factor and using > the numeric levels as your numbers and then put the level labels back on: > > m <- n <- 5 > DF <- data.frame(X = gl(m*n, 1), Y = gl(m, n), Z =

Re: [Rd] reshape scaling with large numbers of times/rows

2006-08-24 Thread Prof Brian Ripley
Here's the essence of a solution (0.14 sec for this bit) res <- with(betterTest, { subjects <- levels(subject) loci <- levels(locus) ## replace "" by as.character(NA) if you prefer res <- matrix("", length(subjects), length(loci), dimnames = list(subjects, loci)) ind <- cbind(as.inte

Re: [Rd] reshape scaling with large numbers of times/rows

2006-08-24 Thread Gabor Grothendieck
On 8/24/06, Mitch Skinner <[EMAIL PROTECTED]> wrote: > On Thu, 2006-08-24 at 08:57 -0400, Gabor Grothendieck wrote: > > If your Z in reality is not naturally numeric try representing it as a > > factor and using > > the numeric levels as your numbers and then put the level labels back on: > > > > m

[Rd] Huge matrices in .Call

2006-08-24 Thread Dominick Samperi
I assume that the fact that SEXP's passed through .Call are read-only is a convention, consistent with R semantics. This can be awkward when huge matrices are passed as in: newP <- .Call("myfunc", P) because this would cause the huge matrix to be copied. Is there any danger if I violate the conve

Re: [Rd] Huge matrices in .Call

2006-08-24 Thread Hin-Tak Leung
Dominick Samperi wrote: > I assume that the fact that SEXP's passed through .Call > are read-only is a convention, consistent with R semantics. > > This can be awkward when huge matrices are passed > as in: > newP <- .Call("myfunc", P) > because this would cause the huge matrix to be copied. Yes,

Re: [Rd] Huge matrices in .Call

2006-08-24 Thread Thomas Lumley
On Thu, 24 Aug 2006, Hin-Tak Leung wrote: > Dominick Samperi wrote: >> I assume that the fact that SEXP's passed through .Call >> are read-only is a convention, consistent with R semantics. Yes >> This can be awkward when huge matrices are passed >> as in: >> newP <- .Call("myfunc", P) >> becaus

[Rd] OT: authorship and contacts for releasing packages (Re: reshape scaling with large numbers of times/rows)

2006-08-24 Thread Hin-Tak Leung
Rather off-topic, not really about R nor development at all, but I think the issue is vaguely relevant for potential package writers. Mitch Skinner wrote: > When there's a chance (however slim, in this case) that something I > write will end up getting used by someone else, I usually use my > per

[Rd] Command line length limits in R

2006-08-24 Thread Prof Brian Ripley
I've been trying to track down some of the issues with command line length limits, and those writing GUIs/front-ends need to pay some attention to the issue. src/unix/system.txt says *int R_ReadConsole(char *prompt, char *buf, int buflen, int hist) * * This function prints the given p