Y Axis Noise in GGplot

Hello, I'm brand new to R and need some beginner's help. I'm just trying to do a basic bar graph, and the Y axis goes crazy and creates noise.

This is my code:

Data3 <- Data2 %>%
select(c(2,7)) %>%
filter(Landings > 1)

ggplot(Data3, aes(x=Year, y=Landings)) + geom_bar(stat="identity") +
labs(x="Year", y="Landings")

I'm not sure if it's the filter I applied? I was just trying to weed out the N/A entries. The new data frame it created looks fine.

Maybe your Landings column is not numeric. What do you get if you run


Landings = col_character()

So I guess that is the problem! How could I fix that please?

Changing the column to be numeric can be as easy as using the as.numeric() function. That would be

Data2$Landings <- as.numeric(Data2$Landings)

That might run into problems depending on the column content. You may get warnings about NA values. It would be good to investigate the source of those NAs but try the command above and let's see how it goes.

That fixed it. Thanks!

This is a dataset for cod catches per year, and I have NA values for years where catches weren't recorded (like during WWII).

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