[R] Using apply() with functions I wrote

Bert Gunter gunter.berton at gene.com
Thu Jul 24 22:11:33 CEST 2014


ummm.... R is case sensitive! "fun" != "FUN"

(Have you gone through any R tutorials yet? If not, please do so
before posting further).

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll




On Thu, Jul 24, 2014 at 10:07 AM, Pfeiffer, Steven <pfeiffss at miamioh.edu> wrote:
> Hello!
>
> Does apply() not work with customized functions?  Here is a simple example:
>
>      AddSeven<-function(n){n+7}
>      AddSeven(3)
>        [1] 10
>      M<-matrix(nrow=2,ncol=2,data=c(1,2,3,4),byrow=TRUE)
>      M
>             [,1] [,2]
>        [1,]    1    2
>        [2,]    3    4
>      apply(x=M,margin=c(1,2),fun=AddSeven)
>        Error in match.fun(FUN) : argument "FUN" is missing, with no default
>
> Thanks for your help!
> -Steve Pfeiffer
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list