[R] convert multi dimensional array to list
arun
smartpink111 at yahoo.com
Thu Oct 4 20:10:06 CEST 2012
Hi,
You can try this:
list2<-lapply(1:dim(my.df.cast)[3],function(i) my.df.cast[,,i,])
names(list2)<-unlist(dimnames(my.df.cast)[3])
list2$May
#, , variable = tmax
#
# name
#year Alf Que
# 2011 18 16
# 2012 18 16
#, , variable = tmin
#
# name
#year Alf Que
# 2011 12 11
# 2012 12 11
list2$May[,,"tmax"]
# name
#year Alf Que
# 2011 18 16
# 2012 18 16
A.K.
----- Original Message -----
From: anto.r <anto.rajaa at gmail.com>
To: r-help at r-project.org
Cc:
Sent: Thursday, October 4, 2012 11:57 AM
Subject: Re: [R] convert multi dimensional array to list
Hi Michael
thanks! That was the option if I kept it an array. The list format with $
sign since it leaves me feeling that the names are there and can be easily
accessed. Why would you rather not use the $ sign?
I use R-Studio and there names can be selected from a drop-down list, I have
found it easier but that could be my lack of proper training in R.
Cheers
Anto
--
View this message in context: http://r.789695.n4.nabble.com/convert-multi-dimensional-array-to-list-tp4645011p4645036.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list