Categories
Mastering Development

trying to compare two countries over time on ggplot

I am stuck in what I’m sure is an extremely simple fix but I just can’t get my head out of the woods enough to actually see the answer. I’m trying to create a ggplot in R of the annual number of hate crimes in two countries between 2012-2018. Now, I’m not great with R and I just need to use it for a thesis, but I’ve made a ggplot successfully before and now that I’m trying to introduce two lines, I’m lost. My dataset has variables “State”, “Year”, “HC Annual Total”. My code is:

theme_set(theme_minimal())
        ggplot(USFR, aes(y =, x =)) +
      geom_line() + 
      geom_point() + 
      labs(x = "Year", y = "HC Count", title = "Hate Crimes in the United States and France")

My problem is essentially that I have no idea what’s supposed to go into the y and x spots? I keep trying different things, like y = HC Annual Total, x = Year, but this only gets me error messages that those objects cannot be found. Any help would be much appreciated, thanks!!!

Edit: the data is here, under the second sheet titled “US/FR”. I uploaded it to R as an xslx file

I then tried this ggplot(data = USFR, aes(y =HC Annual Total, x = Year)
+ geom_line(group = USFR$State) + labs(x = "Year", y = "HC Count",
title = "HC US FR"))

but now I’m getting the error message that says “non-numeric argument to binary operator” even though I do think all my arguments are numeric. No idea what this means or why it occurs!

Leave a Reply

Your email address will not be published. Required fields are marked *