Reputation: 629
After aggregating, "filtering" and parsing a column with date and hours by using as.Date, also transforming it by using melt function, my data looks like this:
DATE variable value
1 13-09-20 Billete_50 20405
2 14-09-20 Billete_50 19808
3 13-09-20 Billete_100 27787
4 14-09-20 Billete_100 20361
5 13-09-20 Total 48192
6 14-09-20 Total 40169
I want a linear graph to show the data, but it looks like this:
It's in spanish, I'm sorry, but the date is almost the same, it may say only September (Sep), but it is showing October, January, April, July, then back to October.
This is my ggplot line:
ggplot(plotCajero1Melted, aes(x=DATE, y=value, col=variable)) + geom_line() +xlab("Fecha") +ylab("Saldo") +ggtitle("Cajero 1")
What should I do? It's something with the date? I was thinking in the year, it is represented in a short way, probably it is making ggplot to have a weird behavior, or maybe a ggplot option that i'm missing?
Upvotes: 0
Views: 126
Reputation: 16178
You're right, your date format is not read as it should be (it seems to be read as Year-Month-Day).
You can modify the date format for example by using the function dmy
from lubridate
package to indicate r
to read the date as Day-Month-Year:
library(lubridate)
df$DATE <- dmy(df$DATE)
ggplot(df, aes(x = DATE, y = value, color = variable))+
geom_line()
Is it what you are looking for ?
Upvotes: 1