0 votes
1 view
in R Programming by (5.3k points)

I would like to use theme_stata for my ggplot. Using the following code, everything works, except for the theme:

df3 <- data_summary(panel_data, varname="invest_amnt", 

                    groupnames=c("trend_id", "path_id"))




df.mean = df3 %>% 

          group_by(path_id) %>% 

        mutate(ymean = mean(invest_amnt))

p <- ggplot(df3, aes(x=path_id, y=invest_amnt, fill=trend_id)) + 

   geom_bar(stat="identity", position=position_dodge()) +

  geom_errorbar(aes(ymin=invest_amnt-sd, ymax=invest_amnt+sd), width=.2,


p + scale_fill_brewer(palette="Paired") + theme_stata() + scale_color_stata()

p + labs(title="", 

         x="path)", y = "Invested Amount")+

   scale_fill_manual(values=c('#f55b5b','#23036b','#e3d613' ))+


       geom_errorbar(data=df.mean, aes(x =path_id , ymax = ymean, ymin = ymean),

                                          size=1.5, linetype = "longdash", inherit.aes = F, width = 1) 

I get the following error message:

Error in theme_stata() : could not find function "theme_stata"

1 Answer

0 votes
by (25.3k points)

In order for your code to work, you need to install the ggthemes package since theme_stata is a part of ggthemes package and not the ggplot2 package.

To install and load ggthemes package:



Welcome to Intellipaat Community. Get your technical queries answered by top developers !