Hi Marna, A bit hard to understand. If raw.data is a record of 11 individuals released at site A at Time 1 and recaptured at either A or B or neither at Time2 or Time3, it doesn't seem to bear any consistent relationship to the numeric coding in table.format or the output at the bottom. Could you explain what the correspondence between the tables is?
Jim On Fri, Dec 18, 2015 at 2:33 PM, Marna Wagley <marna.wag...@gmail.com> wrote: > Hi R users, > I am struggling to create a table in R. I did in Excel but I have a lots of > data and thought it might be easy in R but I am new in R. How to get > "output table" for this example data? > > This is an example. > > ##### > raw.data<-structure(list(Time1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, > 1L, 1L, 1L, 1L), .Label = "SiteA", class = "factor"), Time2 = > structure(c(1L, > 4L, 2L, 1L, 2L, 1L, 2L, 1L, 3L, 3L, 3L), .Label = c("0", "SiteA", > "SiteB", "SiteC"), class = "factor"), Time3 = structure(c(2L, > 2L, 2L, 1L, 2L, 1L, 1L, 3L, 3L, 1L, 3L), .Label = c("0", "SiteA", > "SiteB"), class = "factor")), .Names = c("Time1", "Time2", "Time3" > ), class = "data.frame", row.names = c(NA, -11L)) > > raw.data > > ##### > table.format<-structure(list(Time1 = structure(c(NA, NA, NA, NA, NA, 1L, > NA, > NA, NA, NA, NA, NA, NA, NA, NA, NA), .Label = "Released A", class = > "factor"), > Time2 = structure(c(NA, NA, 2L, NA, NA, NA, 3L, NA, NA, NA, > 4L, NA, NA, NA, 1L, NA), .Label = c("Dead", "Re-captured.at.A", > "Re-captured.at.B", "Re-captured.at.C"), class = "factor"), > Time3 = structure(c(2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, > 4L, 1L, 2L, 3L, 4L, 1L), .Label = c("Dead", "Re-captured.at.A", > "Re-captured.at.B", "Re-captured.at.C"), class = "factor")), .Names = > c("Time1", > "Time2", "Time3"), class = "data.frame", row.names = c(NA, -16L > )) > > table.format > > ### > output<-structure(list(Time1 = c(NA, NA, NA, NA, NA, 11L, NA, NA, NA, > NA, NA, NA, NA, NA, NA, NA), Time2 = c(NA, NA, 3L, NA, NA, NA, > 3L, NA, NA, NA, 1L, NA, NA, NA, 4L, NA), Time3 = c(2L, NA, NA, > 1L, NA, 2L, NA, 1L, 1L, NA, NA, NA, 1L, 1L, NA, 2L)), .Names = c("Time1", > "Time2", "Time3"), class = "data.frame", row.names = c(NA, -16L > )) > > output > > I want to get the table like "output". Any possibility to get it in R? > > I will really appreciate for your help. I am struggling to create this > type of table. > > > Sincerely, > Marna > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.