I want to create plots ('A_plot' and 'B_plot'), and stored in separately object/variables. Below code failed , anyone can help on this ? Thanks!
library(tidyverse)
test_data <- data.frame(
category=c('A','A','A','B','B','B'),
price=c(1,1,2,3,2,2),
amount=c(1:6)
)
for (i in unique(test_data$category)){
paste0(i,'_plot') <- test_data %>% filter(category== i ) %>%
ggplot(aes(x=price,y=amount))+geom_point()+
labs(title=paste0(i,'_plot'))
}