On 2008-January-22  , at 03:10 , Jon Erik Ween wrote:

> That got me there. I suppose R prefers absolute field references in
> scripts rather than macrosubstitutions of field names like you would
> do in pearl or shell scripts?

no, actually, the problem is that apply works on arrays/matrices[1],  
not data.frames. So it converts the rows of your data.frame in an  
array instead of using a one row data.frame, hence you cannot refer to  
the elements of this array by name.
This behavior has also bitten me several times and I would love to  
have an apply function that works on data.frames directly. Is there  
such a modified apply in some package?

[1] ?apply says
"If X is not an array but has a dimension attribute, apply attempts to  
coerce it to an array via as.matrix if it is two-dimensional (e.g.,  
data frames) or via as.array."

JiHO
---
http://jo.irisson.free.fr/

______________________________________________
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