[R] Using apply() with functions I wrote
Peter Alspach
Peter.Alspach at plantandfood.co.nz
Thu Jul 24 22:38:09 CEST 2014
Tena koe Steven
R is case-sensitive. FUN is missing (you have supplied fun - and × and margin) ...
HTH ....
Peter Alspach
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Pfeiffer, Steven
Sent: Friday, 25 July 2014 5:08 a.m.
To: r-help at r-project.org
Subject: [R] Using apply() with functions I 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.
The contents of this e-mail are confidential and may be ...{{dropped:14}}
More information about the R-help
mailing list