Dear all,

I have encountered a bizarre ocurrence: tapply() does not treat the columns of 
data.frame[,cols] in the same way as those of 
data.frame[1:length(data.frame),cols].  Whilst for the latter it identifies the 
"length" of the column to be length(data.frame) in the former it does not seem 
to.  I am enclosing the code where this happens.  Any clues?

asset.t <- sapply(
#       asset[,sapply(asset,is.numeric),drop=T], # returns error "Error in 
tapply(x, frame[row, index], FUN = sum, na.rm = TRUE) :      arguments must 
have same length"
        asset[1:length(asset),sapply(asset,is.numeric)],
        FUN = apply_cols,
        frame = asset,
        index = "NAME"
        )

#       Function definitions

apply_cols <- function(x, frame, row = 1:length(frame), index)
        tapply(
        x,
        frame[row, index],
        FUN=sum,
        na.rm=TRUE
        )
----------
Ivan Alves
Mailto://[EMAIL PROTECTED]

______________________________________________
R-help@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

Reply via email to