0

Hey everyone I am using the inbuilt-dataset economics in Rstudio. I want to create a ggplot and display the personal savings rate (psavert) with different colors of positive and negative values in a time series. I tried the following code, however its not really helping :

new2 <-melt(economics, id=c("date"))
new2[["sign"]] = ifelse(new2[["value"]] >= 0, "positive", "negative")
ggplot(mydata2, aes(x = date, y = value, fill = sign)) + geom_area() + 
scale_fill_manual(values = c("positive" = "blue", "negative" = "red"))

I am unable to plot just the variable psavert. Thank you :)

chandini v
  • 11
  • 4

0 Answers0