Hi there, I am trying to reorganized my data sets so that it is easy for MARK to read it. Basically I have the encounter histories of 1837 butterflies The data looks like this the first 4 columns are the occasions and the last two code for male and female> t1 t2 t3 t4 M F > 1 0 0 0 1 0 male capture on time1 but not seen on time 2, 3 > and 4 > 1 0 0 0 1 0 male capture on time1 but not seen on time 2, 3 > and 4 > 1 0 0 0 0 1 female capture on time1 but not seen on times 2, > 3 and 4 > 1 0 1 1 1 0 male captured on time 1, not seen on time 2, > recaptured on time 3 and 4 > 1 0 1 1 1 0 female captured on time 1, not seen on time 2, > recaptured on occasions 3 and 4 > 1 0 1 1 1 0 female captured on time 1, not seen on time 2, > recaptured on occasions 3 and 4 > 1 0 1 1 1 0 female captured on time 1, not seen on time 2, > recaptured on occasions 3 and 4and I want to convert that into>t1 t2 t3 t4 M F > 1 0 0 0 2 1 Two males and 1 female captured on time1 but not > seen on time 2, 3 and 4 > 1 0 1 1 1 3 One male and two females captured on time 1 and , > not seen on time 2, recapturedon time 3 and 4 I tried to melt it using reshape, but I am getting odd results! Any help is good help! -- View this message in context: http://www.nabble.com/RESHAPE-package-question.-tp18792801p18792801.html Sent from the R help mailing list archive at Nabble.com.
so that you don't get too badly flamed, please do read the posting guide. Give a short, reproducible example of code and data that reproduces you error (i.e. what was the reshape command you tried to use). -Roy M. On Aug 2, 2008, at 1:07 PM, hpdutra wrote:> > Hi there, > > I am trying to reorganized my data sets so that it is easy for MARK > to read > it. > Basically I have the encounter histories of 1837 butterflies > The data looks like this the first 4 columns are the occasions and > the last > two code for male and female > >> t1 t2 t3 t4 M F >> 1 0 0 0 1 0 male capture on time1 but not seen on >> time 2, 3 >> and 4 >> 1 0 0 0 1 0 male capture on time1 but not seen on >> time 2, 3 >> and 4 >> 1 0 0 0 0 1 female capture on time1 but not seen on >> times 2, >> 3 and 4 >> 1 0 1 1 1 0 male captured on time 1, not seen on time 2, >> recaptured on time 3 and 4 >> 1 0 1 1 1 0 female captured on time 1, not seen on >> time 2, >> recaptured on occasions 3 and 4 >> 1 0 1 1 1 0 female captured on time 1, not seen on >> time 2, >> recaptured on occasions 3 and 4 >> 1 0 1 1 1 0 female captured on time 1, not seen on >> time 2, >> recaptured on occasions 3 and 4 > > and I want to convert that into > >> t1 t2 t3 t4 M F >> 1 0 0 0 2 1 Two males and 1 female captured on time1 >> but not >> seen on time 2, 3 and 4 >> 1 0 1 1 1 3 One male and two females captured on time >> 1 and , >> not seen on time 2, recaptured > on time 3 and 4 > > I tried to melt it using reshape, but I am getting odd results! > > Any help is good help! > -- > View this message in context: http://www.nabble.com/RESHAPE-package- > question.-tp18792801p18792801.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.********************** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ********************** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center 1352 Lighthouse Avenue Pacific Grove, CA 93950-2097 e-mail: Roy.Mendelssohn at noaa.gov (Note new e-mail address) voice: (831)-648-9029 fax: (831)-648-8440 www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected"
I am sorry but here is an example> testt1 t2 t3 t4 M F id 1 1 0 0 0 1 0 1 2 1 0 0 0 1 0 1 3 1 0 0 0 0 1 1 4 1 0 1 1 1 0 1 5 1 0 1 1 1 0 1 6 1 0 1 1 1 0 1 7 1 0 1 1 0 1 1> test<-read.table(h=T, file.choose()) > dfm <- melt(test, m = "id") > summarised <- cast(dfm, t1+ t2 + t3 + t4 + M + F ~ variable, sum) > summarisedt1 t2 t3 t4 M F id 1 1 0 0 0 0 1 1 2 1 0 0 0 1 0 2 3 1 0 1 1 0 1 1 4 1 0 1 1 1 0 3 So it works partially because it does not add the male and females columns. I am sure it is simple but I just don't know how to do it. I was hoping that it would give me the following data t1 t2 t3 t4 M F id 1 1 0 0 0 2 1 1 2 1 0 1 1 3 1 1 Many thanks! hpdutra wrote:> > Hi there, > > I am trying to reorganized my data sets so that it is easy for MARK to > read it. > Basically I have the encounter histories of 1837 butterflies > The data looks like this the first 4 columns are the occasions and the > last two code for male and female > >> t1 t2 t3 t4 M F >> 1 0 0 0 1 0 male capture on time1 but not seen on time 2, 3 >> and 4 >> 1 0 0 0 1 0 male capture on time1 but not seen on time 2, 3 >> and 4 >> 1 0 0 0 0 1 female capture on time1 but not seen on times 2, >> 3 and 4 >> 1 0 1 1 1 0 male captured on time 1, not seen on time 2, >> recaptured on time 3 and 4 >> 1 0 1 1 1 0 female captured on time 1, not seen on time 2, >> recaptured on occasions 3 and 4 >> 1 0 1 1 1 0 female captured on time 1, not seen on time 2, >> recaptured on occasions 3 and 4 >> 1 0 1 1 1 0 female captured on time 1, not seen on time 2, >> recaptured on occasions 3 and 4 > > and I want to convert that into > >>t1 t2 t3 t4 M F >> 1 0 0 0 2 1 Two males and 1 female captured on time1 but not >> seen on time 2, 3 and 4 >> 1 0 1 1 1 3 One male and two females captured on time 1 and >> , not seen on time 2, recaptured > on time 3 and 4 > > I tried to melt it using reshape, but I am getting odd results! > > Any help is good help! >-- View this message in context: http://www.nabble.com/RESHAPE-package-question.-tp18792801p18793300.html Sent from the R help mailing list archive at Nabble.com.
That works. I still think you should have named RESHAPE as "MAGIC"! It is amazing how much of a time-saver this tool is! Thanks a lot. -- View this message in context: http://www.nabble.com/RESHAPE-package-question.-tp18792801p18794249.html Sent from the R help mailing list archive at Nabble.com.
On Sat, Aug 2, 2008 at 3:56 PM, hpdutra <hpdutra at yahoo.com> wrote:> > That works. I still think you should have named RESHAPE as "MAGIC"! It is > amazing how much of a time-saver this tool is!Following that suggest would make it even harder for you to find the package you're looking for - there are heaps of "magic" package on CRAN! /Henrik> Thanks a lot. > > > -- > View this message in context: http://www.nabble.com/RESHAPE-package-question.-tp18792801p18794249.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >