简体   繁体   中英

how to combine table(weekdays()) in R

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.

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM