[R] runs.test in by() statement
christiaan pauw
cjpauw at gmail.com
Wed Jan 14 12:38:25 CET 2009
Thanks to Patric and Christian for swift and accurate help
I still had to learn the differnce between calling a function and
passing a call to a function. I had to coerce the first variable to be
a function but then it worked.
by(as.factor(exampledata$var), exampledata$interviewer, runs.test)
Regards
Christiaan
On 14/01/2009, christiaan pauw <cjpauw at gmail.com> wrote:
> exampledata<-data.frame(interviewer=rep(letters[1:2], 1),
> var=round(var=runif(40)))
>
> I do the runs test on "var" and it works
> runs.test(as.factor(exampledata$var))
> I can catagorise the data by "interviewer" and get means using the by()
> statement and that works perfectly
> by(exampledata$var, exampledata$interviewer, mean)
>>
> Why is it impossible to use runs.test() as the function in the by()
> statement instead of mean
> by(exampledata, exampledata$interviewer,
> runs.test(as.factor(exampledata$var)))
> Error in FUN(X[[1L]], ...) : could not find function "FUN"
>
> thanks
> Christiaan
>
More information about the R-help
mailing list