[R] using lapply to get function values
long_vo_hai at yahoo.com.vn
Fri Jan 10 08:04:49 CET 2014
Hi R users,
I need to apply a function on a list of vectors. This is simple when I use
functions that returns only one numerical value such as 'mean' or
'variance'. Things get complex when I use functions returning a list of
value, such as 'acf'.
In the following example I first create a list of vectors with equal length
10. Then I try to get the first order autocorrelation coefficient of each
vector using lapply:
Y=split(X,as.numeric(gl(length(X),10,length(X))))# to divide X into 10
I need to know how to display other values of the function e.g. 'type',
'lag' not just 'acf'. Because using
prompts the error "object of type 'closure' is not subsettable"
Note that this is only an illustrative example. The function I am studying
is not 'acf', but it also return a list of values and I need to call out
Helps and comments are welcome.
View this message in context: http://r.789695.n4.nabble.com/using-lapply-to-get-function-values-tp4683373.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help