[R] Error when using do.call
Brough, Tyler (FRS)
TBrough at russell.com
Tue Feb 22 17:40:32 CET 2005
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
More information about the R-help
mailing list