use the 'sqldf' package. Also use 'dput' to include sample data
since
it was impossible to use the data in the format you provided, so my
guess at a solution would be:
answer <- sqldf("
select ECO_NAME
, count(distinct Order) as Order
, count(distinct Family) as Family
, count(distinct Genus) as Genus
from yourData
group by ECO_NAME
")
Not sure exactly what you wanted in the second question; it would be
nice to include what some sample output would be so we have an idea of
what you are after.
On Fri, May 20, 2011 at 5:18 PM, Chris Mcowen <chrismcowen at gmail.com>
wrote:> 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-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.
>
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?