Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions