前提・実現したいこと
R初学者です。
ggplot2を使って、マリメッコチャートを作っています。
その際にopts関数が使えず、代わりの関数を使いたいのですが、見つけることができません。
対処方法などを、ご教授いただけると幸いでございます。
発生している問題・エラーメッセージ
Error in opts(legend.position = "none", panel.grid.major = theme_line(colour = NA), : could not find function "opts"
該当のソースコード
RStudio
1library(ggplot2) 2dfm <- melt(df, id=c("segment", "xmin", "xmax")) 3head(dfm) 4dfm1 <- ddply(dfm, .(segment), transform, ymax = cumsum(value)) 5dfm1 <- ddply(dfm1, .(segment), transform, ymin = ymax - value) 6dfm1$xtext <- with(dfm1, xmin + (xmax - xmin)/2) 7dfm1$ytext <- with(dfm1, ymin + (ymax - ymin)/2) 8p <- ggplot(dfm1, aes(ymin = ymin, ymax = ymax, xmin =xmin, xmax = xmax, fill = variable)) 9p1 <- p + geom_rect(colour = I("grey")) 10p2 <- p1 + geom_text(aes(x = xtext, y = ytext, label = ifelse(segment == "1st", paste(variable, " _ ", value, "%", sep = ""), paste(value, "%", sep = ""))), size=4) 11p3 <- p2 +geom_text(aes(x = xtext, y = 103, label = paste(segment)), size = 5) 12p3 + theme_bw()+ labs(x = NULL, y= NULL, fill = NULL)+ opts(legend.position = "none", panel.grid.major = theme_line(colour = NA), panel.grid.minor = theme_line(colour = NA)) 13last_plot()+ scale_fill_brewer(palette = "Set2")
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/10 03:53