Problem with R Studio graphing

I'm in a data science class and we've been asked to interpret or analyze a particular dataset, and I've wanted to make a predictive model of F1 drivers. This is SUPPOSED to be a graph of Verstappen's final race position over time, starting with his first. However, the y-axis isnt in order and the lines are simply horizontal, and I dont understand why. Any help is appreciated.


Verstappen2 <- subset(Verstappen, (Verstappen$position != "\N"))

ggplot(Verstappen2) + geom_line(aes(x = raceId, y = position)) + ggtitle("Line Graph of Race Position")


Hi @c_good98. It looks like the position variable is character or factor. Try changing this variable to numeric.

Thanks for the reply. Since its in a dataframe, how would I do that?

If your dataframe is df, you could do the following:

df$position = as.numeric(df$position)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.