0

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: Linear plot

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?

0

1 Answer 1

1

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()

enter image description here

Is it what you are looking for ?

Sign up to request clarification or add additional context in comments.

3 Comments

Absolutely, thank you so much, you saved my day. I applied for a javascript+python+sql Job, there said "R desirable but not required" and the test they sent me is only about R, very funny haha. I started learning about it 23 hours ago.
Haha ! Good luck then ;) Fingers crossed
dc37 Thak you :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.