how to combine table(weekdays()) in R

73 views Asked by At

I want to combine 3 table(weekdays()) in R with library(twitteR) and library(ROAuth) no more.

I am doing it with tweets. My job is combine created days(what days) from 3 tweets.

 a=table(weekdays(dsADF[,"created"]))  
 b=table(weekdays(dsBDF[,"created"]))

 c=table(weekdays(dsCDF[,"created"]))

Let's say from a I've got Monday :100, Tuesday : 200

From b, Monday =30, tuesday = 40, thursday= 130, friday = 200 from c whatever

How I can combine three tables? without any library functions? I will use it to draw a plot.

1

There are 1 answers

0
G. Grothendieck On BEST ANSWER

Convert them to data frames, combine them with rbind and convert back with xtabs.

a <- as.table(c(Monday = 100, Tuesday = 200))
b <- as.table(c(Monday = 30, Tuesday = 40, Thursday= 130, Friday = 200))
xtabs(Freq ~ Var1, rbind(as.data.frame(a), as.data.frame(b)))

giving:

Var1
  Monday  Tuesday Thursday   Friday 
     130      240      130      200