There is too little information to answer your question definitively. 

However, an obvious reason is that you want to apply the function over
columns of a data.frame, which is done with apply(), but you try to apply
the function over elements of a list using lapply(). A list is not a
data.frame and vice versa, which would be a good reason for your function to
fail. The below example works:

data=data.frame(y=rnorm(100),x=rnorm(100),e=rnorm(100))

f=function(x){quantile(x,probs=0.25)}

apply(data,2,f)

Also, for debugging, you want to disassemble the whole and check whether the
individual parts work. Does the "function()" work when applied on just one
column, for example? If not, then you also have a problem with the
definition of the function. If so, you would have to check, whether the
quantile or IQR function fails in one of the instances.

HTH,
Daniel
-- 
View this message in context: 
http://r.789695.n4.nabble.com/function-tp2196408p2196445.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to