My data:
structure(list(YEAR = structure(1:10, .Label = c("1980", "1981",
"1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989"
), class = "factor"), lupas = c(1185, 822, 1340, 853, 3018, 1625,
966, 1505, 1085, 1754)), .Names = c("YEAR", "lupas"), row.names = c(NA,
-10L), class = c("tbl_df", "tbl", "data.frame"), drop = TRUE)
I've group the data with group_by from dplyr.
str(df1)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 10 obs. of 2 variables:
$ YEAR : Factor w/ 10 levels "1980","1981",..: 1 2 3 4 5 6 7 8 9 10
$ lupas: num 1185 822 1340 853 3018 ...
- attr(*, "drop")= logi TRUE
I'm trying to plot a graph of the years, and the "lupas" each year. Like a time series graph.
This is my code, but gives an error:
ggplot(df1,
aes(x = YEAR, y = lupas)) +
geom_line()
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
And this graph:
After reading this thread: ggplot2 each group consists of only one observation
I've changed my code to:
ggplot(df1,
aes(x = YEAR, y = lupas)) +
geom_line(position=position_dodge(.1))
Now i get this message:
ymax not defined: adjusting position using y instead
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?