Reputation: 915
I'm trying to do what in theory should be the easiest thing ever but i'm making some mistake that I can't even understand.
I would like to plot $Number of Fatalities by $Month on a scatterplot, (and eventually facet_wrap by $State but that's not where i'm having issues).
Here is my attempt:
library(tidyverse) fatalities <- read.csv(filename.csv) fatalities = as.data.frame(fatalities) ggplot(data = fatalities)+ geom_point(mapping = aes(x = Month, y = Number of Fatalities))
...and here is the output:
Error: unexpected symbol in: "ggplot(data = fatalities) + geom_point(mapping = aes(x = Month, y = Number of"
This is the dataset i'm using: https://data.gov.au/dataset/5b530fb8-526e-4fbf-b0f6-aa24e84e4277/resource/0e3771a4-4783-4a12-89ac-b48892bb3ba0/download/bitrearddfatalcrashesfebruary2018.csv
Your help with this or how I could rephrase the question is greatly appreciated - thank you!
Upvotes: 3
Views: 25085
Reputation: 1659
Can't have spaces in variable names. Wrap them with graves/backticks (`) to make it clear to R that it is a single name.
geom_point(mapping = aes(x = Month, y = `Number of Fatalities`))
Upvotes: 5