[R] 'Apply' giving me errors

kickout kyle.kocak at gmail.com
Fri Oct 21 02:09:36 CEST 2011


So i have a simple function:

bmass=function(y){
weight=y$WT*y$MSTR
return(bio)
}

And want to apply to a whole bunch of rows in my data.frame:

final1=apply(final,1,yldbu)


BUT...recieve the following error:
"Error in y$WT : $ operator is invalid for atomic vectors"


However when i try:
> final[1,]$WT*final[1,]$MSTR
[1] 156.3


It gives me the correct answer....what is apply not liking in my code?

Thanks



--
View this message in context: http://r.789695.n4.nabble.com/Apply-giving-me-errors-tp3923880p3923880.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list