Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How should I atribute names to a list, to work with ggplot function?

I created a list of lists, each one representing one variable by doing this

names(needed_data) <- c(
  "Ano", "Casamentos Hungria", "Casamentos Eslovénia",
  "Casamentos Noruega", "Divórcios Hungria", 
  "Divórcios Eslovénia","Divórcios Noruega"
)

Then I proceeded to use needed_data in a ggplot function, but when I write, for example aes(x = "Ano", y = "Casamentos Hungria") I don’t think R-Studio "understands" this code. How should I name the list, so that it works.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

aes() uses tidy evaluation – try either

aes(x = Ano, y = `Casamentos Hungria`)

or

aes_string(x = "Ano", y = "`Casamentos Hungria`")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading