glenn roberts wrote:
I have got a general problem when applying a function to a dataframe using
the function;

Apply(df,1,myfunct)


Do you mean "apply"? Or does the "Aaply" function come from a separate package?


Where myfunct has an IF statement in it along the lines of;

If (z == 0)
X = 1
If (z ==0)
Z = 1

I.e. Two If statements

Is there something I am missing or have a just formed the if statements
wrong ­ just checking there is not some trick you have to use when using
apply with functions with if statements in.

The function works fine in isolation with df[1,.] say

You are forgetting to include details here, specifically, a reproducible example of a function called 'myfunct' that exhibits the behavior you aren't expecting.

'myfunct' is going to have to take a parameter (say, 'x') that contains the data. If you call it 'x', you might try replacing z above by x["z"] perhaps? It's difficult to say more until we have more details.

______________________________________________
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