Comparing multiple data frames

梦想的初衷 提交于 2019-12-04 23:32:21

Here are a couple of ideas.

This is what I think your data look like?

before <- data.frame(val=c(11330,2721,52438,6124),
                     lab=c("STAT1","STAT2","STAT3","SUZY"))
after <- data.frame(val=c(17401,3462,0,72),
                     lab=c("STAT1","STAT2","STAT3","SUZY"))

Combine them into a single data frame with a period variable:

combined <- rbind(data.frame(before,period="before"),
      data.frame(after,period="after"))

Reformat to a matrix and plot with (base R) dotchart:

library(reshape2)
m <- acast(combined,lab~period,value.var="val")
dotchart(m)

Plot with ggplot:

library(ggplot2)
qplot(lab,val,colour=period,data=combined)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!