Skip to content
Prev 275052 / 398506 Next

'Apply' giving me errors

On Fri, Oct 21, 2011 at 3:09 AM, kickout <kyle.kocak at gmail.com> wrote:
But this just returns "bio" and since an object with that name is not
defined in the function, it will be looked up in the global
environment (workspace) and if it's not there either, you will get
Error: object 'bio' not found. So even if you could fix the apply
"issue" it would still not work. But Uwe Ligges showed you don't need
apply to do what you seem to intend here, final$WT*final$MSTR should
work.

But if you do insist on apply for whatever reason then ... apply
converts X (the first argument) to a matrix so you can't use the $
operator any more. The column names are preserved though, so what you
could do is

bmass <- function(y) y["WT"] * y["MSTR"]
apply(final, 1, bmass)
What is yldbu? I suppose you meant the function you defined above?

Kenn