Adding data points on a plot in r -
Hi I have a simple plot of the year and the number of births in those years. I want to create a graph / row on which x is the number on the year and y is the number. My code is far below 'x' should be numeric: when i run it i get error error (x) in jitter. This plot is based on a dataframe DF. Any help would be greatly appreciated.
#plot (df $ number), (df $ sex), xlab = "x", ylab = "y", type = "l", main = "my graph") plot ($ Years, df $ number) df x = df $ y y = df $ number #plot (x, y) par (march = c (3,3,2,1), mpg = c (2,0.7,0 ), Las = 1) plot (x, y, type = "n", xaxt = "n", yaxt = "n", las = 1, xlab = "year", ylab = "") Number =) axis (1, on = beautiful (x), label = TRUE) (2, = beautiful (y, n = 10) axis, las = 1) #grid () digits (jitter (x), y, col = "Blue", pch = 20) # dot (jitter (df $ number))
< P> See
class ( X)
or class (df $ year)
. Depending on the data, it is easy to see that the year is being considered as a factor.
Comments
Post a Comment