[R] Puzzled by an error with apply()

Gang Chen gangchen6 at gmail.com
Tue Apr 7 04:04:34 CEST 2009


I've written a function, myFunc, that works fine with myFunc(data,
...), but when I use apply() to run it with an array of data

apply(myArray, 1, myFunc, ...)

I get a strange error:

Error in match.fun(FUN) : '1' is not a function, character or symbol

which really puzzles me because '1' is meant to be the margin of the
array I want to apply over, but how come does apply() treat it as a
function?

I have been successfully using apply() for a while, so I must have
made a stupid mistake this time. Hopefully somebody can point out
something obviously wrong without me providing any details of the
function.

TIA,
Gang




More information about the R-help mailing list