[R] Would you please help me to create a table in R?

Marna Wagley marna.wagley at gmail.com
Fri Dec 18 18:57:19 CET 2015


Dear Jim,
I am sorry for not explaining the question in a clear way. I am trying to
explain it, let's see how much clear I can make it.

For the given example, (raw.data). Let's say, the 11 birds were marked and
released at site A in a landscape (a combination of sites siteA, siteB,
site C) in 2010.

In 2011, we revisited at the sites (siteA, SiteB, SiteC), among the 11
birds, we recaptured 3 individuals at Site A, 3 at Site B, 1 at site C but
we could not see 4 individuals at any sites.

Again in 2012, we revisited at the sites (SiteA, SiteB, SiteC), we again
recaptured 2 individuals which was recaptured at Site A in 2011 but 1
individual could not seen at any sites (in another words: in 2011 at the
site A  we had recaptured 3 individuals, among them 2 were again seen at
site A, but we could not see one individual in any sites).

Similarly,we had recaptured 3 individuals in 2011 at the site B, but in
2012, among three individuals, one was again recaptured in Site B but 2
individuals could not be seen at any sites.

Likewise, for SiteC in 2012, we had recaptured 1 at that site (siteC), but
in next year (2012), we could not see at any of the sites.

Again, we had not seen 4 individuals in 2011, but later in 2012, among
these 4 individuals, we recaptured one individual for each site  B and C,
and 2 individuals could not be seen.

I have given the example dataset. If it is really confusing and takes your
lots of time, please forget it, I will try to do in Excel manually,but it
is taking so much time and easily making errors. Your help will be very
useful.

Sincerely,


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("NotSeen", "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("NotSeen", "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

##################################################
####################################################


On Thu, Dec 17, 2015 at 11:38 PM, Jim Lemon <drjimlemon at gmail.com> wrote:

> 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.wagley at 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 at 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]]



More information about the R-help mailing list