[R] Would you please help me to create a table in R?
Marna Wagley
marna.wagley at gmail.com
Fri Dec 18 04:33:02 CET 2015
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]]
More information about the R-help
mailing list