[R] Listing elements of a 4D array
arun
smartpink111 at yahoo.com
Thu Nov 22 03:52:18 CET 2012
Hi,
I tested the first two snippets of data.
#Try this:
junk.melt1<-junk.melt[order(junk.melt[,1]),]
y<-cast(junk.melt1, Site ~ Rep ~ Especie ~ Año)
#Seems ordered to me.
A.K.
________________________________
From: Andrea Goijman <agoijman at cnia.inta.gov.ar>
To: arun <smartpink111 at yahoo.com>
Sent: Wednesday, November 21, 2012 8:53 PM
Subject: Re: [R] Listing elements of a 4D array
Hi,
I'm not really sure how to use "dput()", so here is some little sample of my data. After doing the reshape process, the names of the species are al mixed up, and I just need to know the order in which they are listed in my new array, because I'm classifying them in functional groups using a vector: species.groups=c(1,2,3,4,...177) which indicates the which species belonw to which groups (I would also appreciate input on that! although I could do something if i know the order of the species in my new array)
> occ.data[1:20,]
Año Ruta_com Point Site Especie Pres Rep Punto
1 2003 105 3 1051 AMHU 1 3 NA
2 2003 105 3 1051 ANAN 1 3 NA
3 2003 105 2 1051 EGTH 1 2 NA
4 2003 105 1 1051 FURU 1 1 NA
5 2003 105 4 1051 FURU 1 4 NA
6 2003 105 3 1051 GUGU 1 3 NA
7 2003 105 1 1051 MICH 1 1 NA
8 2003 105 2 1051 MICH 1 2 NA
9 2003 105 3 1051 MICH 1 3 NA
10 2003 105 4 1051 MISA 1 4 NA
11 2003 105 1 1051 MOBO 1 1 NA
12 2003 105 2 1051 MOBO 1 2 NA
13 2003 105 5 1051 MOBO 1 5 NA
14 2003 105 5 1051 MORU 1 5 NA
15 2003 105 2 1051 MYMO 1 2 NA
16 2003 105 2 1051 NOMA 1 2 NA
17 2003 105 3 1051 NOMA 1 3 NA
18 2003 105 5 1051 NOMA 1 5 NA
19 2003 105 3 1051 PADO 1 3 NA
20 2003 105 4 1051 PADO 1 4 NA
> occ.data[15700:15720,]
Año Ruta_com Point Site Especie Pres Rep Punto
15700 2004 407 8 4072 ZOCA 1 3 NA
15701 2004 407 10 4072 ZOCA 1 5 NA
15702 2004 407 11 4073 AMHU 1 1 NA
15703 2004 407 13 4073 AMHU 1 3 NA
15704 2004 407 15 4073 AMHU 1 5 NA
15705 2004 407 14 4073 ANAN 1 4 NA
15706 2004 407 11 4073 COCA 1 1 NA
15707 2004 407 15 4073 COLI 1 5 NA
15708 2004 407 11 4073 COME 1 1 NA
15709 2004 407 14 4073 COME 1 4 NA
15710 2004 407 11 4073 COPZ 1 1 NA
15711 2004 407 13 4073 COPZ 1 3 NA
15712 2004 407 11 4073 GUGU 1 1 NA
15713 2004 407 12 4073 MICH 1 2 NA
15714 2004 407 14 4073 MICH 1 4 NA
15715 2004 407 12 4073 MISA 1 2 NA
15716 2004 407 15 4073 MISA 1 5 NA
15717 2004 407 13 4073 MOBO 1 3 NA
15718 2004 407 13 4073 MYMO 1 3 NA
15719 2004 407 11 4073 NOMA 1 1 NA
15720 2004 407 11 4073 PADO 1 1 NA
> occ.data[35700:35720,]
Año Ruta_com Point Site Especie Pres Rep Punto
35700 2006 102 2 1021 ZEAU 1 2 NA
35701 2006 102 3 1021 ZEAU 1 3 NA
35702 2006 102 4 1021 ZEAU 1 4 NA
35703 2006 102 5 1021 ZEAU 1 5 NA
35704 2006 102 1 1021 ZOCA 1 1 NA
35705 2006 102 4 1021 ZOCA 1 4 NA
35706 2006 102 6 1022 ANAN 1 1 NA
35707 2006 102 9 1022 BUIB 1 4 NA
35708 2006 102 9 1022 COME 1 4 NA
35709 2006 102 10 1022 COME 1 5 NA
35710 2006 102 10 1022 ELPA 1 5 NA
35711 2006 102 10 1022 EMAU 1 5 NA
35712 2006 102 6 1022 FURU 1 1 NA
35713 2006 102 7 1022 FURU 1 2 NA
35714 2006 102 9 1022 FURU 1 4 NA
35715 2006 102 8 1022 GUGU 1 3 NA
35716 2006 102 10 1022 GUGU 1 5 NA
35717 2006 102 6 1022 MISA 1 1 NA
35718 2006 102 7 1022 MISA 1 2 NA
35719 2006 102 8 1022 MOBA 1 3 NA
35720 2006 102 9 1022 MOBA 1 4 NA
> occ.data[55700:55720,]
Año Ruta_com Point Site Especie Pres Rep Punto
55700 2007 207 13 2073 EMPL 1 3 NA
55701 2007 207 15 2073 FASP 1 5 NA
55702 2007 207 13 2073 FULE 1 3 NA
55703 2007 207 12 2073 FURU 1 2 NA
55704 2007 207 12 2073 GUGU 1 2 NA
55705 2007 207 14 2073 GUGU 1 4 NA
55706 2007 207 15 2073 GUGU 1 5 NA
55707 2007 207 13 2073 HIME 1 3 NA
55708 2007 207 13 2073 LAMA 1 3 NA
55709 2007 207 12 2073 MARI 1 2 NA
55710 2007 207 14 2073 MICH 1 4 NA
55711 2007 207 12 2073 MISA 1 2 NA
55712 2007 207 15 2073 MYMO 1 5 NA
55713 2007 207 13 2073 NEPE 1 3 NA
55714 2007 207 13 2073 OXVI 1 3 NA
55715 2007 207 15 2073 PADO 1 5 NA
55716 2007 207 11 2073 PEPY 1 1 NA
55717 2007 207 13 2073 PEPY 1 3 NA
55718 2007 207 14 2073 PEPY 1 4 NA
55719 2007 207 11 2073 PLCH 1 1 NA
55720 2007 207 12 2073 PLCH 1 2 NA
> occ.data[1:20,]
Año Ruta_com Point Site Especie Pres Rep Punto
1 2003 105 3 1051 AMHU 1 3 NA
2 2003 105 3 1051 ANAN 1 3 NA
3 2003 105 2 1051 EGTH 1 2 NA
4 2003 105 1 1051 FURU 1 1 NA
5 2003 105 4 1051 FURU 1 4 NA
6 2003 105 3 1051 GUGU 1 3 NA
7 2003 105 1 1051 MICH 1 1 NA
8 2003 105 2 1051 MICH 1 2 NA
9 2003 105 3 1051 MICH 1 3 NA
10 2003 105 4 1051 MISA 1 4 NA
11 2003 105 1 1051 MOBO 1 1 NA
12 2003 105 2 1051 MOBO 1 2 NA
13 2003 105 5 1051 MOBO 1 5 NA
14 2003 105 5 1051 MORU 1 5 NA
15 2003 105 2 1051 MYMO 1 2 NA
16 2003 105 2 1051 NOMA 1 2 NA
17 2003 105 3 1051 NOMA 1 3 NA
18 2003 105 5 1051 NOMA 1 5 NA
19 2003 105 3 1051 PADO 1 3 NA
20 2003 105 4 1051 PADO 1 4 NA
> occ.data[25700:25720,]
Año Ruta_com Point Site Especie Pres Rep Punto
25700 2005 219 17 2194 SPCU 1 2 NA
25701 2005 219 18 2194 SPCU 1 3 NA
25702 2005 219 19 2194 SPCU 1 4 NA
25703 2005 219 20 2194 SPCU 1 5 NA
25704 2005 219 19 2194 STSU 1 4 NA
25705 2005 219 20 2194 STSU 1 5 NA
25706 2005 219 19 2194 TYSA 1 4 NA
25707 2005 219 18 2194 VACH 1 3 NA
25708 2005 219 19 2194 VACH 1 4 NA
25709 2005 219 16 2194 VOJA 1 1 NA
25710 2005 219 17 2194 ZEAU 1 2 NA
25711 2005 219 18 2194 ZEAU 1 3 NA
25712 2005 219 19 2194 ZEAU 1 4 NA
25713 2005 219 16 2194 ZOCA 1 1 NA
25714 2005 219 18 2194 ZOCA 1 3 NA
25715 2005 219 19 2194 ZOCA 1 4 NA
25716 2005 219 20 2194 ZOCA 1 5 NA
25717 2005 219 23 2195 AMHU 1 3 NA
25718 2005 219 23 2195 ANAN 1 3 NA
25719 2005 219 23 2195 COCA 1 3 NA
25720 2005 219 24 2195 COLI 1 4 NA
> occ.data[45700:45720,]
Año Ruta_com Point Site Especie Pres Rep Punto
45700 2006 620 7 6202 MOBO 1 2 NA
45701 2006 620 6 6202 MYMO 1 1 NA
45702 2006 620 7 6202 MYMO 1 2 NA
45703 2006 620 8 6202 MYMO 1 3 NA
45704 2006 620 7 6202 NOMA 1 2 NA
45705 2006 620 10 6202 NOMA 1 5 NA
45706 2006 620 9 6202 PHST 1 4 NA
45707 2006 620 10 6202 PHST 1 5 NA
45708 2006 620 8 6202 PHTA 1 3 NA
45709 2006 620 9 6202 PHTA 1 4 NA
45710 2006 620 7 6202 PISU 1 2 NA
45711 2006 620 6 6202 PONI 1 1 NA
45712 2006 620 8 6202 RHRU 1 3 NA
45713 2006 620 8 6202 SILU 1 3 NA
45714 2006 620 9 6202 STSU 1 4 NA
45715 2006 620 9 6202 TALE 1 4 NA
45716 2006 620 9 6202 TRAE 1 4 NA
45717 2006 620 8 6202 TYSA 1 3 NA
45718 2006 620 9 6202 TYSA 1 4 NA
45719 2006 620 8 6202 VACH 1 3 NA
45720 2006 620 7 6202 XOCI 1 2 NA
> occ.data[75700:75720,]
Año Ruta_com Point Site Especie Pres Rep Punto
75700 2008 305 25 3055 PACO 1 5 NA
75701 2008 305 23 3055 PADO 1 3 NA
75702 2008 305 25 3055 PISU 1 5 NA
75703 2008 305 22 3055 POPL 1 2 NA
75704 2008 305 25 3055 POPL 1 5 NA
75705 2008 305 22 3055 PSLO 1 2 NA
75706 2008 305 21 3055 PYRU 1 1 NA
75707 2008 305 21 3055 SIFL 1 1 NA
75708 2008 305 23 3055 SIFL 1 3 NA
75709 2008 305 25 3055 SIFL 1 5 NA
75710 2008 305 22 3055 SILU 1 2 NA
75711 2008 305 23 3055 SILU 1 3 NA
75712 2008 305 24 3055 SILU 1 4 NA
75713 2008 305 25 3055 SILU 1 5 NA
75714 2008 305 21 3055 SPCA 1 1 NA
75715 2008 305 22 3055 STSU 1 2 NA
75716 2008 305 24 3055 STSU 1 4 NA
75717 2008 305 25 3055 STSU 1 5 NA
75718 2008 305 25 3055 TRAE 1 5 NA
75719 2008 305 23 3055 TYSA 1 3 NA
75720 2008 305 21 3055 VACH 1 1 NA
On Wed, Nov 21, 2012 at 8:02 PM, arun <smartpink111 at yahoo.com> wrote:
Hi,
>
>It would be great if you could provide a small example dataset using dput().
>
>A.K.
>
>
>----- Original Message -----
>From: Andrea Goijman <agoijman at cnia.inta.gov.ar>
>To: R help <r-help at r-project.org>
>Cc:
>Sent: Wednesday, November 21, 2012 6:35 PM
>Subject: [R] Listing elements of a 4D array
>
>Dear list,
>
>I'm having trouble to see how my elements on a 4 dimensional array are
>listed.
>
>For example, I generated the following array:
>
>junk.melt=melt(occ.data,id.var=c("Especie", "Site", "Rep", "Año"),
>measure.var="Pres")
>y=cast(junk.melt, Site ~ Rep ~ Especie ~ Año)
>
>Now, I want to be able to look at how my species (Especie) are listed, in
>which order.
>
>I found that they are not listed in alphabetical order (using rudimentary
>data management skills). Is there a way to reorder them in alphabetical
>order? and if not, how do I see the order of my 277 species?
>
>Thank you,
>
>
>
>--
>---
>Lic. Andrea Paula Goijman
>Grupo Ecología y Gestión Ambiental de la Biodiversidad
>IRB - INTA Castelar, Argentina
>agoijman at cnia.inta.gov.ar
><http://inta.gob.ar/personas/goijman.andrea/>
>http://inta.gob.ar/personas/goijman.andrea/
>
>PhD Candidate
>Georgia Cooperative Fish and Wildlife Research Unit
>D.B. Warnell School of Forestry and Natural Resources
>University of Georgia
>Athens, GA 30602 USA
>Tel. +706.206.4805
>andreapg at uga.edu
>
> [[alternative HTML version deleted]]
>
>
>______________________________________________
>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.
>
>
--
---Lic. Andrea Paula Goijman
Grupo Ecología y Gestión Ambiental de la Biodiversidad
IRB - INTA Castelar, Argentina
agoijman at cnia.inta.gov.arhttp://inta.gob.ar/personas/goijman.andrea/
PhD Candidate
Georgia Cooperative Fish and Wildlife Research Unit
D.B. Warnell School of Forestry and Natural Resources
University of Georgia
Athens, GA 30602 USA
Tel. +706.206.4805
andreapg at uga.edu
More information about the R-help
mailing list