Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] Error when using do.call

Brough, Tyler (FRS)

2005-02-22


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@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.