R 使用ggplot2的多重条形图
根据这个例子,我试着画出以下几点 数据集如下所示:R 使用ggplot2的多重条形图,r,ggplot2,R,Ggplot2,根据这个例子,我试着画出以下几点 数据集如下所示: df <- structure(list(year = 2002:2005, work = c(1L, 2L, 3L, 2L), confid = c(8L, 5L, 0L, 6L), jrs = c(0L, 3L, 4L, 5L)), .Names = c("year", "work", "confid", "jrs"), class = "data.frame", row.names = c(NA, -4L )) 我试图从图形中
df <- structure(list(year = 2002:2005, work = c(1L, 2L, 3L, 2L), confid = c(8L,
5L, 0L, 6L), jrs = c(0L, 3L, 4L, 5L)), .Names = c("year", "work",
"confid", "jrs"), class = "data.frame", row.names = c(NA, -4L
))
我试图从图形中删除opts(),但再次收到相同的错误
可能是什么问题?使用
主题
替换选项
的代码更新版本:
df <- structure(list(year = 2002:2005, work = c(1L, 2L, 3L, 2L), confid = c(8L,
5L, 0L, 6L), jrs = c(0L, 3L, 4L, 5L)), .Names = c("year", "work",
"confid", "jrs"), class = "data.frame", row.names = c(NA, -4L
))
library(ggplot2)
library(reshape)
md <- melt(df, id=(c("year")))
temp.plot <- ggplot(data=md, aes(x=year, y=value, fill=variable) ) +
geom_bar(stat="identity")+
theme(axis.text.x=element_text(angle=90))+
ggtitle("Score Distribtion")
temp.plot
df这是用于ggplot的旧版本<代码>选项
已替换为主题
。使用labs
或ggtitle
获取标题。
Error: could not find function "opts"
df <- structure(list(year = 2002:2005, work = c(1L, 2L, 3L, 2L), confid = c(8L,
5L, 0L, 6L), jrs = c(0L, 3L, 4L, 5L)), .Names = c("year", "work",
"confid", "jrs"), class = "data.frame", row.names = c(NA, -4L
))
library(ggplot2)
library(reshape)
md <- melt(df, id=(c("year")))
temp.plot <- ggplot(data=md, aes(x=year, y=value, fill=variable) ) +
geom_bar(stat="identity")+
theme(axis.text.x=element_text(angle=90))+
ggtitle("Score Distribtion")
temp.plot