I'm a bit new to R - I've been trying to wrap an R script as a function so I can call it from Rserve. Does anyone know why ggplot2 would not work inside a function yet works just fine outside of it?
png('polarity.png')
ggplot(sent_df, aes(x=polarity)) +
geom_bar(aes(y=..count.., fill=polarity)) +
scale_fill_brewer(palette="RdGy") +
labs(x="polarity categories", y="number of conversatins") +
opts(title = "Sentiment Analysis of Posts on Facebook\n(classification by polarity)",
plot.title = theme_text(size=12))
dev.off()
This may have something to do with it ggplot2 produces error when used in function or S4 but I'm not getting an error that I can detect - I just get no output.