Hi all, can you please clarify me what is the wrong with following codes :

set.seed(30)
z = matrix(rnorm(10), 5, 2)
apply(z, 1, function(x) sum(z[x,1]*1, z[x,2]*3))

However I can not get the desired result. For example, "sum(z[1,1]*1,
z[1,2]*3)" gives -5.822442 which is actually correct. Am I missing something
in apply() function?

Regards,


-- 
View this message in context: 
http://www.nabble.com/Help-on-apply%28%29-function-tp23288839p23288839.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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