[R] sapply puzzlement

David A. Johnston dajohnston at ucdavis.edu
Fri Jan 28 01:45:39 CET 2011


sapply(z, function(row) ...) does not actually grab a row at a time out of
'z'. It grabs a column (because 'z' is a data.frame)

You may want:
t(apply(z, 1, function(row) row - means))

or:

t(t(z) - means)


Hope that helps,

-David Johnston
-- 
View this message in context: http://r.789695.n4.nabble.com/sapply-puzzlement-tp3243520p3243534.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list