[R] Error when using do.call
Liaw, Andy
andy_liaw at merck.com
Tue Feb 22 19:41:34 CET 2005
Why not just do:
do.call("order", A[, ind])
?? A data frame is already a list.
Andy
> From: Brough, Tyler (FRS)
>
> useRs,
>
> I'm using version 2.0.1 on Windows XP. I am a bit of a
> newbie and I am
> trying to learn the concept of computing on the language. I
> have an example
> that I think ought to work, but will not and I am not sure
> what I am doing
> wrong.
>
> I would like to sort a data frame by a list of columns.
> Eventually I would
> like to wrap this in a function so that I could sort data
> frames by a list
> determined from context. Any suggestions? Thanks for your
> patience as I
> strive to learn some of the finer points.
>
> Here is a reproduction of the problem:
>
> #*************************************************************
> **************
> *************************
> A <- data.frame(X = sample(c("A","B"),size=10,replace=T), Y =
> sample(c(T,F),size = 10, replace = T),
> Z = sample(1:10,size=10,replace=T));
>
> arglist <- list();
> ind <- 3:1
> for(i in 1:3) {
> arglist[[i]] <- as.name(paste("A[,",ind[i],"]",sep=""));
> }
>
> do.call(what="order",args=arglist)
> #*************************************************************
> **************
> *************************
>
> I get the following error message:
>
> > do.call(what="order",args=arglist)
> Error in order('A[,3]','A[,2]','A[,1]') :
> Object "A[,1]" not found
> >
>
> Thanks,
>
> -Tyler
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
More information about the R-help
mailing list