Dear Martin and dear all,

I tried your approach but I suppose it does not work...
my commands are the following, where's my mistake?

> head(dune)
   Belper Empnig Junbuf Junart Airpra Elepal Rumace Viclat Brarut Ranfla
Cirarv
2       3      0      0      0      0      0      0      0      0
0      0
13      0      0      3      0      0      0      0      0      0
2      0
4       2      0      0      0      0      0      0      0      2
0      2
16      0      0      0      3      0      8      0      0      4
2      0
6       0      0      0      0      0      0      6      0      6
0      0
1       0      0      0      0      0      0      0      0      0
0      0
   Hyprad Leoaut Potpal Poapra Calcus Tripra Trirep Antodo Salrep Achmil
Poatri
2       0      5      0      4      0      0      5      0      0
3      7
13      0      2      0      2      0      0      2      0      0
0      9
4       0      2      0      4      0      0      1      0      0
0      5
16      0      0      0      0      3      0      0      0      0
0      2
6       0      3      0      3      0      5      5      3      0
2      4
1       0      0      0      4      0      0      0      0      0
1      2
   Chealb Elyrep Sagpro Plalan Agrsto Lolper Alogen Brohor
2       0      4      0      0      0      5      2      4
13      1      0      2      0      5      0      5      0
4       0      4      5      0      8      5      2      3
16      0      0      0      0      7      0      4      0
6       0      0      0      5      0      6      0      0
1       0      4      0      0      0      7      0      0

> names.A <- names(dune)[dune[1]>0] # this takes the names of line 1, that
is sample 2, right?
> names.A <- names(dune)[dune[2]>0] # this takes the names of line 2,
...right?

> names.A
[1] "Trirep"

> names.B
 [1] "Belper" "Empnig" "Junbuf" "Airpra" "Rumace" "Viclat" "Brarut" "Ranfla"
 [9] "Cirarv" "Hyprad" "Leoaut" "Potpal" "Poapra" "Calcus" "Tripra" "Trirep"
[17] "Antodo" "Salrep" "Achmil" "Poatri" "Chealb" "Sagpro" "Agrsto" "Lolper"
[25] "Alogen" "Brohor"


if you look to the dataframe dune, the sample lies in line 1 doeas not have
only the "Trirep" species, similarly I do not know how it give me 26
species for the second samples...
Where is the problem?
Sorry for this stupid questions, but I am a rusty R-user :)

Thanks for helping,

Gian





On 3 February 2014 20:42, Martin Weiser <weiser2@natur.cuni.cz> wrote:

> Hi Gian,
>
> there are many ways to do it. In the line with my previous post, you can
> do:
> new.data <- dune[c(Line.number.where.sampleA.I.am.interested.in.lies,
> Line.number.where.sampleB.I.am.interested.in.lies), ]
>
> and proceed with the new.data like with the dune (as I wrote you
> already)
>
> another approach:
>
> species.names.from.the.sampleA <-
> names(dune)[dune[Line.number.where.sampleA.I.am.interested.in.lies,]>0]
> species.names.from.the.sampleB
> <-names(dune)[dune[Line.number.where.sampleB.I.am.interested.in.lies,]>0]
> multiple.occurrences <-
>
> c(species.names.from.sampleA,species.names.from.sampleB)[duplicated(c(species.names.from.sampleA,species.names.from.sampleB))]
> single.occurrences <-
> unique(c(species.names.from.sampleA,species.names.from.sampleB))
>
> HTH
> Martin
>
>
>
>
>
> -------- Přeposlaná zpráva --------
> > Od: Gian Maria Niccolò Benucci <gian.benucci@gmail.com>
> > Komu: r-sig-ecology@r-project.org
> > Předmět: Re: [R-sig-eco] how to detect different species among samples
> > Datum: Mon, 3 Feb 2014 17:50:51 +0100
> >
> > Hi Martin,
> >
> > thanks a lot. Also your commands are working... It's very nice to see how
> > different solutions in R can be found for a single problem.
> > I just have another question now, but... if I would know which species
> are
> > in common (and which not) between two particular selected samples?
> > Thanks for the brainstorming :)
> >
> > Gian
> >
> >
> >
> >
> >
> > On 3 February 2014 17:01, Martin Weiser <weiser2@natur.cuni.cz> wrote:
> >
> > > Hi,
> > > I am not sure that I get what you wanted, but if you are interested in
> > > names, I propose something like this:
> > >
> > > is.there <- dune
> > > is.there[is.there > 1] <- 1 #change counts to presence/absence data
> > > number.of.samples <- colSums(is.there)
> > > single.occurrences<-names(dune)[number.of.samples ==1]
> > > multiple.occurrences <- names(dune)[number.of.samples > 1]
> > >
> > > HTH,
> > > Martin
> > >
> > > what about:Gian Maria Niccolò Benucci píše v So 01. 02. 2014 v 14:08
> > > +0100:
> > > > Hi Sarah,
> > > >
> > > > I am sorry, I'll try to be more precise. Given a dataset like...
> > > >
> > > > > data(dune)
> > > > > dune[1:8, 1:10]
> > > >    Belper Empnig Junbuf Junart Airpra Elepal Rumace Viclat Brarut
> Ranfla
> > > > 2       3      0      0      0      0      0      0      0      0
>    0
> > > > 13      0      0      3      0      0      0      0      0      0
>    2
> > > > 4       2      0      0      0      0      0      0      0      2
>    0
> > > > 16      0      0      0      3      0      8      0      0      4
>    2
> > > > 6       0      0      0      0      0      0      6      0      6
>    0
> > > > 1       0      0      0      0      0      0      0      0      0
>    0
> > > > 8       0      0      0      4      0      4      0      0      2
>    2
> > > > 5       2      0      0      0      0      0      5      0      2
>    0
> > > >
> > > > In this dataset we can see that the first species, named Belper, is
> > > present
> > > > in samples 2, 4 and 5 but is absent in samples 13, 16 and so on...
> Now my
> > > > question is, how can I extract the names of the species (and even
> their
> > > > abundances) that are common and the species that are not common
> between
> > > the
> > > > different samples in my dataset?
> > > >
> > > > Many thanks in advance,
> > > >
> > > > --
> > > > Gain
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On 1 February 2014 13:42, Sarah Goslee <sarah.goslee@gmail.com>
> wrote:
> > > >
> > > > > Hi Gian,
> > > > >
> > > > > I don't understand what you're trying to do. Can you give a simple
> > > example
> > > > > of your data and what your results should be?
> > > > >
> > > > > Sarah
> > > > >
> > > > > On Saturday, February 1, 2014, Gian Maria Niccol Benucci <
> > > > > gian.benucci@gmail.com> wrote:
> > > > >
> > > > >> Hi all R-sig-ecologists,
> > > > >>
> > > > >>
> > > > >> Sorry for the very simple and probably stupid question. I was
> > > wandering if
> > > > >> exist a simple method or a function in R, to detect which
> different
> > > > >> species
> > > > >> are present among the samples of a given data community matrix.
> > > > >> Thanks a lot in advance,
> > > > >>
> > > > >> --
> > > > >> Gian
> > > > >>
> > > > >
> > > > >
> > > > > --
> > > > > Sarah Goslee
> > > > > http://www.stringpage.com
> > > > > http://www.sarahgoslee.com
> > > > > http://www.functionaldiversity.org
> > > > >
> > > >
> > > >       [[alternative HTML version deleted]]
> > > >
> > > > _______________________________________________
> > > > R-sig-ecology mailing list
> > > > R-sig-ecology@r-project.org
> > > > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> > >
> > >
> > >
> > >
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-ecology mailing list
> > R-sig-ecology@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
>
>

	[[alternative HTML version deleted]]

