[R-sig-eco] Multiple count if style "queries"
Eduard Szöcs
szoe8822 at uni-landau.de
Sat May 21 00:49:38 CEST 2011
Like this?
dfc2 <- cast(dfm, ECO_NAME ~ variable + value, length)
Eduard
Am 21.05.2011 00:39, schrieb Chris Mcowen:
> Hi Eduard,
>
> That is a handy package, i hadn't come across.
>
> The ouput from dcf is perfect.
>
> But for dfm:
>
> ECO_NAME Order Family
> 134 Central Range montane rain forests Zingiberales Zingiberaceae
> 269 Central Range montane rain forests Zingiberales Zingiberaceae
> 364 Biak-Numfoor rain forests Asparagales Orchidaceae
> 500 Central Range montane rain forests Asparagales Orchidaceae
> 566 Central Range montane rain forests Poales Centrolepidaceae
> 567 Huon Peninsula montane rain forests Poales Centrolepidaceae
> 755 Central Range montane rain forests Asparagales Lomandraceae
> 906 Huon Peninsula montane rain forests Asparagales Orchidaceae
> 1079 Central Range montane rain forests Zingiberales Zingiberaceae
> 1175 Central Range montane rain forests Asparagales Orchidaceae
> 1271 Central Range montane rain forests Poales Cyperaceae
> 1421 Central Range montane rain forests Poales Eriocaulaceae
> 1581 Huon Peninsula montane rain forests Asparagales Orchidaceae
> 1621 Biak-Numfoor rain forests Alismatales Araceae
> 1622 Central Range montane rain forests Alismatales Araceae
> 1811 Central Range montane rain forests Poales Cyperaceae
> 1928 Central Range montane rain forests Commelinales Commelinaceae
> 2141 Central Range montane rain forests Poales Poaceae
> 2142 Huon Peninsula montane rain forests Poales Poaceae
> 2276 Central Range montane rain forests Poales Poaceae
> 2391 Huon Peninsula montane rain forests Asparagales Orchidaceae
> 2525 Central Range montane rain forests Asparagales Orchidaceae
> 2526 Huon Peninsula montane rain forests Asparagales Orchidaceae
> 2660 Central Range montane rain forests Asparagales Orchidaceae
>
> I would want to count how many time a order appears in each eco_name and then how many times a family appears in each eco_name and how many times a genus appears in each eco_name.
>
> For example to ask the question: How many Zingiberaceae family are there in Central Range montane rain forests? But to query this for each eco_name.
>
> I hope this makes sense.
>
> Chris
>
>
>
>
> On 20 May 2011, at 23:23, Eduard Szöcs wrote:
>
> Using the reshape package:
>
> require(reshape)
> dfm<- melt(data2, id = "ECO_NAME")
> dfc<- cast(dfm, ECO_NAME~variable, function(x) length(unique(x)))
>
>
> Eduard
>
> Am 20.05.2011 23:19, schrieb Chris Mcowen:
>> Dear List,
>>
>> I am looking to calculate two things from my data frame and was after some advice. For the example below i want to know.
>>
>> 1. How many unique Orders/Families and Genera there are per eco-name
>>
>> 2. How many incidences are there for each Order/Family and Genus there are per eco-region
>>
>> I have 650 econame.
>>
>> I.e for Biak-Numfoor rain forests there are 2 orders, 2 families and two genera. Also, Alismatales are represented once, Asparagales once etc etc.
>>
>> Thanks for any advice.
>>
>> Chris
>>
>>
>> ECO_NAME Order Family Genus
>> Biak-Numfoor rain forests Alismatales Araceae Homalomena
>> Biak-Numfoor rain forests Asparagales Orchidaceae Bromheadia
>> Central Range montane rain forests Alismatales Araceae Homalomena
>> Central Range montane rain forests Asparagales Lomandraceae Cordyline
>> Central Range montane rain forests Asparagales Orchidaceae Thelymitra
>> Central Range montane rain forests Asparagales Orchidaceae Dendrobium
>> Central Range montane rain forests Asparagales Orchidaceae Vanda
>> Central Range montane rain forests Asparagales Orchidaceae Bulbophyllum
>> Central Range montane rain forests Asparagales Orchidaceae Bulbophyllum
>> Central Range montane rain forests Asparagales Orchidaceae Dendrobium
>> Central Range montane rain forests Asparagales Orchidaceae Dendrobium
>> Central Range montane rain forests Commelinales Commelinaceae Murdannia
>> Central Range montane rain forests Poales Centrolepidaceae Centrolepis
>> Central Range montane rain forests Poales Cyperaceae Machaerina
>> Central Range montane rain forests Poales Cyperaceae Eleocharis
>> Central Range montane rain forests Poales Eriocaulaceae Eriocaulon
>> Central Range montane rain forests Poales Poaceae Schizostachyum
>> Central Range montane rain forests Poales Poaceae Poa
>> Central Range montane rain forests Zingiberales Zingiberaceae Alpinia
>> Central Range montane rain forests Zingiberales Zingiberaceae Curcuma
>> Central Range montane rain forests Zingiberales Zingiberaceae Amomum
>> Huon Peninsula montane rain forests Asparagales Orchidaceae Taeniophyllum
>> Huon Peninsula montane rain forests Asparagales Orchidaceae Corybas
>> Huon Peninsula montane rain forests Asparagales Orchidaceae Thelymitra
>> Huon Peninsula montane rain forests Asparagales Orchidaceae Glomera
>> Huon Peninsula montane rain forests Poales Centrolepidaceae Centrolepis
>> Huon Peninsula montane rain forests Poales Poaceae Poa
>>
>> _______________________________________________
>> R-sig-ecology mailing list
>> R-sig-ecology at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>>
> _______________________________________________
> 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