[R] Problem with "list"
Peter Ehlers
ehlers at ucalgary.ca
Sun Sep 19 12:37:23 CEST 2010
On 2010-09-19 4:21, Christofer Bogaso wrote:
> Dear all, I have following list object:
>
> dat<- vector("list", length=4)
> for(i in 1:4) dat[[i]]<- diag(rnorm(5)^2)
> names(dat)<- paste("A", 1:4, sep="")
>
> It is ok upto this point. However if I want apply, suppose chol()
> function on any of it's element, I am getting error:
>
>> chol(dat['A1'])
> Error in chol.default(dat["A1"]) : non-numeric argument to 'chol'
>
> Can somebody point me where I am doing wrong?
You need another set of brackets:
chol(dat[['A1']])
-Peter Ehlers
More information about the R-help
mailing list