[R] apply vs. sapply

About this list Date view Thread view Subject view Author view Attachment view

From: Christian Schulz (ozric@web.de)
Date: Sun 22 Dec 2002 - 03:30:31 EST


Message-id: <009901c2a90e$553ca7f0$863f07d5@c5c9i0>

Hi,

sapply((1:NCOL(hermes)),function(x) hist(hermes[,x],main=names(hermes)[x]))

.......this works , but i would like use it with apply to generate many plots in one step!

####################################################################

>>apply((1:ncol(hermes)),2,function(x) hist(hermes[,x],main=names(hermes)[x]))
Error in apply(1:ncol(hermes), 2, function(x) hist(hermes[, x], main = names(hermes)[x])) :
        dim(X) must have a positive length

>>apply(hermes[,1:6],2,function(x) hist(hermes[,x],main=names(hermes)[x]))
Error in hist.default(hermes[, x], main = names(hermes)[x]) :
        `x' must be numeric

>>apply(hermes,2,function(x) hist(hermes[,x],main=names(hermes)[x]))
Error in hist.default(hermes[,x ], main = names(hermes)[x]) :
        `x' must be numeric

thanks for advance & regards

        [[alternate HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jun 2004 - 09:31:59 EST