Trouble with ggplot

Hey all, I'm brand new to R and would appreciate some help. None of my friends could figure out what is wrong with my code or data, but every time I plot a graph it ends up looking something like this (see picture attached). This happens to almost any graph I plot so potentially something is wrong with my computer? If anyone could give me a hand it would be much appreciated.

This is the code I used:
ggplot(data = economic_consideration,
aes(x = 'ethnicity', y = 'percentage employed', colour = State)) + geom_point()

You need to add backticks for the column names:
A small hint to remember this: if the column names are coloured in the same text as ordinary text it is interpreted as text and not as a variable. (in my RStudio setting it's red, but this isn't the default)

library(tidyverse)

# generating fake data with long column names
cars = mpg %>% 
  rename("mpg in the city" = cty,
         "mpg on the highway" = hwy)

# this doesn't work as the columns are interpreted as text
ggplot(cars, aes(x = 'mpg in the city',
                 y = 'mpg on the highway')) +
         geom_jitter()

# this is working       
ggplot(cars, aes(x = `mpg in the city`,
                 y = `mpg on the highway`)) +
  geom_jitter()

PS: for the ethnicity you don't need any ticks at all.

Do it without the apostrophe:

ggplot(data = economic_consideration,
aes(x = ethnicity, y = percentage employed , colour = State)) + geom_point()

Ok thank you. The back ticks didn't change anything but I added geom_jitter and got an actual graph. But now I've run into two more problems.
Firstly, the graph has a constant in it, that is victorians per 100,000 features at the same point on every x co-ordinate.
Secondly, when I try to add a scale with: scale_y_continuous(breaks = seq(etc...) it tells me -> Error: Discrete value supplied to continuous scale
The data is very clearly continuous, so I'm very confused. Could anyone give me a hand?

What does your dataset look like? Can you provide a reprex?

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.