[R] Fwd: filter out many data.frames

Christian Schulz ozric at web.de
Sun May 16 17:17:31 CEST 2004


> So, why are you doing these complicated things?

Hmm, want upgrade my sklls, because
i need more and more function's to reduce
complexity in my analysis. 
And try , do.call and match.call seems very usefuel and 
i want at long last understand the flexbilty of this functions.

>
> Just using
>      names(theList) <- apply(data, 1, paste, collapse="")
> (you want to replace data by the corrected name) after your loop in your
> first version would be sufficient, if you are going to name the list
> elements....

Yes many thanks, now it works and nrow or others things
could be easy changed or add.

Chrstian 


data <- expand.grid(class02 = c("A","B","C","D"), class04 = 
c("A","B","C","D"),PREDICT = c("A","B","C","D"))
tList  <- vector("list", numeric(nrow(data)))
#names(tList) <- apply(data, 1, paste, collapse="")
tasign <- paste("tList[[n]]  <-   try(nrow(dtree[dtree$class02 == 
paste(data$class02[n]) & dtree$class04 == paste(data$class04[n]) & 
dtree$PREDICT==paste(data$PREDICT[n]),]))")
tasign <-  parse(text=tasign)[[1]]
          
for(n in 1:nrow(data)) {
  TAsign <- do.call("substitute",list(tasign,list(n=n,X=as.name(n))))
  eval(TAsign)
}

names(tList) <- apply(data, 1, paste, collapse="")
results <- as.data.frame(unlist(dfl))
names(results) <- c("n")
results




More information about the R-help mailing list