根据this示例,我尝试绘制以下内容
数据集如下:
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()+ opts(axis.text.x=theme_text(angle=90)) +
opts(title = "Score Distribtion")
我收到错误:
Error: could not find function "opts"
我试图从图中删除opts(),但我又收到同样的错误。
这可能是什么问题?
答案 0 :(得分:0)
代码的更新版本使用theme
代替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