-2

I'm trying to plot a simple bar graph in R, using ggplot in R3.1.1 on Windows 8. Here's a code segment:

ggplot(sent_df, aes(x=emotion))
+ geom_bar(aes(y=..count.., fill=emotion))
+ scale_fill_brewer(palette="Dark2")
+ labs(x="emotion categories", y="number of comments")
+ opts(title = "classification by emotion", plot.title = theme_text(size=12)) 

with sent_df the dataframe, but getting an error:

Error: Use 'theme' instead. (Defunct; last used in version 0.9.1)"

Dave Cousineau
  • 12,154
  • 8
  • 64
  • 80
Mudit
  • 13
  • 1

1 Answers1

0

opts is not used anymore. Instead you have to use theme try this

    ggplot(sent_df, aes(x=emotion)) + geom_bar(aes(y=..count.., fill=emotion)) + 
scale_fill_brewer(palette="Dark2") + labs(x="emotion categories", y="number of comments",
title = "classification by emotion") + theme(plot.title = element_text(size=12))

For further details just look at ggplot2 documentation.

Koundy
  • 5,265
  • 3
  • 24
  • 37