0

Currently my code is:

ggplot(data.frame,
       aes(y = Less.Than.1.Year, x = Rate)) +
  geom_point()

I am getting the following graph, but the y values in the axis are jumbled up like this:

Graph 1

What could be the reason?

Also, when I add more data points to the same data frame and in the same format, it gets completely messed up, like this:

Graph 2

Data format: Rate Data Less.Than.1.Year Data

  • 3
    Without a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), I'd guess you have a factor instead of numeric variable on your y-axis – camille Jan 08 '20 at 20:02
  • Thank you! How can I figure out if this is the case, and if so, how can I change it? – student999 Jan 08 '20 at 20:04
  • 1
    `class(a)` tells you the class of some object `a`, such as a data frame column. If it's a factor, convert to numeric – camille Jan 08 '20 at 20:05
  • Thank you very much! This partially fixed the problem, but now my x-axis only displays three values, even though I have close to 18 distinct x-values that are repeated multiple times for each y-value. Any idea why that could be? – student999 Jan 08 '20 at 20:27
  • 2
    Like I said, we can't see any of your data and we can't run your code without it, so I don't know – camille Jan 08 '20 at 20:31
  • Apologies, I understand what you mean now. I added the descriptive statistics of my data at the end of the post. The Rate variable is interest rate points between 0.00 and 5.00 The Less.Than.1.Year is percentage points between 0.00 and 100.00 Thank you again! – student999 Jan 08 '20 at 20:42
  • The link in my first comment has several suggested ways to post data. We can't run code on a picture of a printout of descriptive statistics, and that doesn't show the types of your data. Either way, I'm almost certain the issue is that you're plotting a factor where you want to plot a numeric – camille Jan 08 '20 at 22:54

0 Answers0