Question
I have some plots I want generate in R: I am using ggplot. When I run the commands below the are drawn and it works
I have some plots I want generate in R: I am using ggplot. When I run the commands below the are drawn and it works fine. When I put them in a loop the plots are not drawn. How do I put the ggplot command into a loop and have the plots be drawn?
D1, D2, D3 are columns in the mydataframe
my_category_col is a factor
I want to put the following three commands into a loop:
ggplot(mydataframe, aes(x = D1, y = my_category_col)) +
geom_density_ridges(aes(fill = my_category_col)) +
scale_fill_manual(values = c("#00AFBB", "#E7B800", "#FC4E07", "purple")) +
theme(legend.position = "none")
ggplot(mydataframe, aes(x = D2, y = my_category_col)) +
geom_density_ridges(aes(fill = my_category_col)) +
scale_fill_manual(values = c("#00AFBB", "#E7B800", "#FC4E07", "purple")) +
theme(legend.position = "none")
ggplot(mydataframe, aes(x = D3, y = my_category_col)) +
geom_density_ridges(aes(fill = my_category_col)) +
scale_fill_manual(values = c("#00AFBB", "#E7B800", "#FC4E07", "purple")) +
theme(legend.position = "none")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started