[R-sig-eco] How to change the pattern of my dataset??

Peter Solymos solymos at ualberta.ca
Tue Dec 21 10:09:00 CET 2010


Yong Zhang,

I think this is what you are looking for:

library(mefa)
x <- matrix(c(
           2,      3,      4,     2,
           5,      6,      5,     2,
           4,      3,      4,     5,
           4,      5,      4,     1), 4, 4, byrow=TRUE)
colnames(x) <- c("site1",  "site2", "site3", "site4")
rownames(x) <- c("A",  "B", "C", "D")
melt(as.mefa(t(x)))

HTH,

Peter

ps: just had seen a wonderful lunar eclipse at winter solstice, once
in every 372 years...



2010/12/21 Yong Zhang <2010202035 at njau.edu.cn>:
> Dear all
>
> I have to appologize in advance , because I am very new about this. Thing is like this, now I have a dataset containing species abundance, species names and sampling sites. See below:
>
>           site1  site2 site3 site4.............
> A           2      3      4     2
> B           5      6      5     2
> C           4      3      4     5
> D           4      5      4     1
> .
> .
> .
> .
> .
> .
> .
> .
> How should I do to change it into a dataset like below:
> site1 A 2
> site1 B 5
> site1 C 4
> site1 D 4
> .
> .
> .
> .
> .
> .
>
> site2 A 3
> site2 B 6
> site2 C 3
> site2 D 5
> .
> .
> .
> .
> .
> .
> site3 A 4
> site3 B 5
> site3 C 4
> site3 D 4
> .
> .
> .
> .
> .
> site4 A 2
> site4 B 2
> site4 C 5
> site4 D 1
> .
> .
> .
> .
> .
> .
> .
>
> Could one know which package should I take?  And, which function shou I use? Please answer in details if you can. Thanks very much for you time and suggestion.
>
> All the best.
>
>
>
>
> Yong Zhang, Ph.D.
> Lab of aquatic insects & stream ecology
> Dept.of Entonology, Nanjing Agricultural University
> Nanjing, 210095,China
> Phone number:  (+86) -25-84395241
> E-mail:2010202035 at njau.edu.cn
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
>



More information about the R-sig-ecology mailing list