[R-sig-eco] Problem in Search and Association Loop
Alexandre F. Souza
alexsouza.cb.ufrn.br at gmail.com
Sun Sep 6 01:08:14 CEST 2015
Hello Fabrice, hello Hanna,
Thank you very much for your responses to my question. Both your
suggestions were helpful and worked nicely.
Best wishes,
Alexandre
2015-09-05 10:52 GMT-03:00 Fabrice Dessaint <fabrice.dessaint at dijon.inra.fr>
:
>
> Hello Alexandre,
>
> I am writing a loop to compare scientific plant names from one data frame
> in a second data frame containing a smaller set of potentially different
> plant names, and then to copy the associated abundances of the sp already
> present in the first database, and add the new species to the bottom.
>
>
> Perhaps, you can use merge() function ?
>
> > base <- data.frame(
> +
> family=c("Burseraceae","Anacardiaceae","Euphorbiaceae","Anacardiaceae","Apocynaceae",
> + "Sapotaceae","Malpighiaceae","Polygonaceae","Burseraceae"),
> +
> genus=c("Coccoloba","Tapirira","Pogonophora","Thyrsodium","Himatanthus","Pouteria",
> + "Byrsonima","Coccoloba","Protium"),
> + epithet=c("cf.
> cordifolia","guianensis","schomburgkiana","spruceanum","phagedaenicus",
> + "coriacea","sericea","cf. cordifolia","heptaphyllum"),
> + abundance=c(224,112,146,115,47,71,25,29,37))
> >
> > new.base <- data.frame(
> + genus=c("Coccoloba","Protium","Bowdichia","Sclerolobium","Ocotea"),
> + epithet=c("cf.
> cordifolia","heptaphyllum","virgilioides","densiflorum","glomerata"),
> + abundance=c(29,37,15,15,16))
> >
> > merge.data.frame(base,new.base,by=c("genus", "epithet"), all=TRUE)
> genus epithet family abundance.x abundance.y
> 1 Byrsonima sericea Malpighiaceae 25 NA
> 2 Coccoloba cf. cordifolia Burseraceae 224 29
> 3 Coccoloba cf. cordifolia Polygonaceae 29 29
> 4 Himatanthus phagedaenicus Apocynaceae 47 NA
> 5 Pogonophora schomburgkiana Euphorbiaceae 146 NA
> 6 Pouteria coriacea Sapotaceae 71 NA
> 7 Protium heptaphyllum Burseraceae 37 37
> 8 Tapirira guianensis Anacardiaceae 112 NA
> 9 Thyrsodium spruceanum Anacardiaceae 115 NA
> 10 Bowdichia virgilioides <NA> NA 15
> 11 Ocotea glomerata <NA> NA 16
> 12 Sclerolobium densiflorum <NA> NA 15
>
>
> Fabrice
>
> ---
> Fabrice Dessaint
>
> UMR 1347 Agroécologie
> INRA/AgroSup/uB
> 17 rue Sully,
> BP 86510 F-21065 Dijon Cedex
> Tel: +33 (0)3 80 69 31 83
> ———————————————————————————
> ResearchID: http://www.researcherid.com/rid/F-1102-2014
> ORCID: http://orcid.org/0000-0001-9135-598X
> ResearchGate: http://www.researchgate.net/profile/Fabrice_Dessaint
>
>
>
>
>
>
>
--
Dr. Alexandre F. Souza
Professor Adjunto III
Universidade Federal do Rio Grande do Norte
CB, Departamento de Ecologia
Campus Universitário - Lagoa Nova
59072-970 - Natal, RN - Brasil
lattes: lattes.cnpq.br/7844758818522706
http://www.docente.ufrn.br/alexsouza
[[alternative HTML version deleted]]
More information about the R-sig-ecology
mailing list