Skip to content
Prev 334270 / 398502 Next

Splitting a vector

This does what I needed. However, as the output is a list object, is there
any way to apply a function to such object? For example if I want to compute
the mean for the 4th subvectors, I can't simply use:
#####
Y=split(X,as.numeric(gl(length(X),3,length(X))))
mean(Y[4])
##### 
as the error message shows "argument is not numeric or logical"



--
View this message in context: http://r.789695.n4.nabble.com/Splitting-a-vector-tp4681930p4681987.html
Sent from the R help mailing list archive at Nabble.com.