> p <- min_var %>%
+ gather(MSFT:RTN.L, key = Asset,
+ value = Weights) %>%
+ mutate(Asset = as.factor(Asset)) %>%
+ ggplot(aes(x = fct_reorder(Asset,Weights), y = Weights, fill = Asset)) +
+ geom_bar(stat = 'identity') +
+ theme_minimal() +
+ labs(x = 'Assets', y = 'Weights', title = "Minimum Variance Portfolio Weights") +
+ scale_y_continuous(labels = scales::percent)
>
> ggplotly(p)
Error in fct_reorder(Asset, Weights) :
could not find function "fct_reorder"
^ Can somebody help? Not sure where to go from here. Thank you.