[R] Splitting a vector

Long Vo long_vo_hai at yahoo.com.vn
Wed Dec 11 03:03:56 CET 2013


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.



More information about the R-help mailing list