> -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Matthew Venesky > Sent: Monday, April 29, 2013 8:13 AM > To: r-help@r-project.org > Subject: [R] expanding a presence only dataset into presence/absence > > Hello, > > I'm working with a very large dataset (250,000+ lines in its' current > form) > that includes presence only data on various species (which is nested > within > different sites and sampling dates). I need to convert this into a dataset > with presence/absence for each species. For example, I would like to > expand > "My current data" to "Desired data": > > My current data > > Species Site Date > a 1 1 > b 1 1 > b 1 2 > c 1 3 > > Desired data > > Species Present Site Date > a 1 1 1 > b 1 1 1 > c 0 1 1 > a 0 2 2 > b 1 2 2 > C 0 2 2 > a 0 3 3 > b 0 3 3 > c 1 3 3 > > I've scoured the web, including Rseek and haven't found a resolution (and > note that a similar question was asked sometime in 2011 without an > answer). > Does anyone have any thoughts? Thank you in advance. >
Matthew, You need to clarify your requirements before anyone can help you. Your presence-only data only contains one site, but your desired data has three. How are we to know how many sites there are? Also, your presence-only data has species c present at site 1 on date 3, but it is not present in your desired data. It is not at all clear (nor is it deducible) how you get from your example data to your desired data. If you clarify your requirements, maybe someone will be able to help. Dan Daniel Nordlund Bothell, WA USA ______________________________________________ R-help@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.