I'm trying to draw a simple line plot using ggplot geom_line()
my code is very simple:
df <- as.data.frame(table(data()$Date))
colnames(df) <- c('Date','value')
volPlot <- ggplot(data = df, aes(x = Date,y = value))
volPlot <- volPlot + geom_point(size = 3) + geom_line(size = 3)
return(volPlot)
df looks like this:
Date value
1 2016-06-01 379
2 2016-06-02 262
3 2016-06-03 264
4 2016-06-04 167
5 2016-06-06 410
The plot shows the points but no line in between them which is what I want
Note: the console returns the following message:
geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?
So I suppose the problem comes from my data structure but I don't know how to prevent this, any help would be nice.
EDIT: Solution was found, you need to add group = 1 in the aes:
volPlot <- ggplot(data = df, aes(x = Date,y = value, group = 1))