[R-sig-eco] Presence-absence to Occurrence Dataset?

Tom_Philippi at nps.gov Tom_Philippi at nps.gov
Fri Apr 20 21:06:42 CEST 2012


Elyse--

For the first step of converting your community matrix to triplets of
{site, species, presence}, you can use melt() from the flexible & powerful
reshape package as David suggested, or dematrify() from Dave Roberts'
labdsv package, which was built specifically for this task and has simpler
syntax than melt.  The second step is to then merge your location dataframe
with the long-format occurrence data by sitenames.

Do you need coordinates for only presences, or for presences and absences?
If you need only presences, dematrify() with thresh=0.5 would automatically
drop absences, while melt() would require a second step LongOccurrences <-
LongOccurrences[Freq>0,]

So, (untested code) for dataframes named CommMatrix and SiteCoords and
sitenames as Site:
LongOccurrences <- dematrify(CommMatrix,thresh=0.5)
Presences <- merge(LongOccurrences,SiteCoords,by="Site",all.x=TRUE)

If you have more complex needs for handling community and environmental
data, you might consider the mefa package.

Tom
-------------------------------------------
Tom Philippi
Quantitative Ecologist
Inventory and Monitoring Program
National Park Service
c/o Cabrillo National Monument
1800 Cabrillo Memorial Dr
San Diego, CA 92106
(619) 523-4576
Tom_philippi at NPS.gov
http://science.nature.nps.gov/im/monitor
-------------------------------------------



                                                                           
             David Valentim                                                
             Dias                                                          
             <dvdscripter at gmai                                          To 
             l.com>                    "r-sig-ecology at r-project.org"       
             Sent by:                  <r-sig-ecology at r-project.org>       
             r-sig-ecology-bou                                          cc 
             nces at r-project.or                                             
             g                                                     Subject 
                                       Re: [R-sig-eco] Presence-absence to 
                                       Occurrence Dataset?                 
             04/20/2012 01:32                                              
             PM AST                                                        
                                                                           
                                                                           
                                                                           
                                                                           




You can check melt() (from reshape2) and reshape() functions.


2012/4/20 Coffey, Elyse D. (UMSL-Student) <edc6cb at mail.umsl.edu>

> Hello everyone,
>
> I am working with a large community dataset where column names are
species
> and rows are filled with either 1s or 0s (presence absence of the
species)
> and each row corresponds to a site name.  I have long and lati
coordinates
> for each site in a separate datasheet.
>
> I am trying to use a program called Maxent in order model species
> distributions. The program requires a specific occurrence dataset with
> columns in this format: species, Long, Lati.
>
> It is very difficult and time consuming to create such a dataset by hand!
> I was wondering if anyone had any ideas as to how I can use R to
manipulate
> my original community dataset in order to create the occurrence dataset I
> described above?
>
> Any suggestions would be greatly appreciated!
>
> Thanks,
>
> Elyse Coffey
> Biology (B.S.) student
> University of Missouri-St. Louis
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>



--
Currículo: http://lattes.cnpq.br/7541377569511492

             [[alternative HTML version deleted]]

_______________________________________________
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