0

I am trying to use ggplot(). The datatype of Percentage is Double. In the dataset, there is no NAs in both Percentage and Year columns.

l1 <- ggplot(data, aes(Year, Percentage)) + 
  scale_x_discrete(name="Year From 2015 to 2018") + 
  scale_y_discrete(name="Employment Outcomes")

The error said:

Error in if (zero_range(from) || zero_range(to)) { : 
  missing value where TRUE/FALSE needed
Z.Lin
  • 28,055
  • 6
  • 54
  • 94
YYYYY
  • 39
  • 1
  • 6
  • 3
    To make your problem [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), can you edit your question to include the output from `dput(data)`? Also you haven't included any `geom_*` / `stat_*` layer. What do you intend to plot? – Z.Lin Apr 26 '19 at 13:58

1 Answers1

0

In your case, you need to specify what type of visualization you want to generate. For example, if you want to visualize time series plot, the scripts would be like this.

ggplot(data, aes(Year, Percentage)) + 
  geom_line() +
  scale_x_discrete(name="Year From 2015 to 2018") + 
  scale_y_discrete(name="Employment Outcomes")

Basically, you need to specify geom_*() after ggplot(). Also, another advice from me is that, use labs() not scale_x_discrete() to add names on X/Y axis.

ggplot(data, aes(Year, Percentage)) + 
  geom_line() +
  labs(x = "Year From 2015 to 2018",
       y = "Employment Outcomes")

This generates similar plot that you want.

koki25ando
  • 74
  • 6