In a R dataframe I have time variable. The data is in the format %a-%b-%d %H:%M:%S. for e.g.,
2015-03-23 20:00:00
I want to get the following data only
20:00:00
I have created a table basis the above said variable and trying to make a line graph:
Var1 Var2 Freq
1 2015-03-24 00:00:00 RT 612
2 2015-03-24 01:00:00 RT 65
3 2015-03-24 06:00:00 RT 58
4 2015-03-24 07:00:00 RT 5132
5 2015-03-24 08:00:00 RT 4483
6 2015-03-24 09:00:00 RT 11112
I have used the following code to make a ggplot line graph:
library(ggplot2)
library(stringr)
ggplot(rtt, aes(x = as.factor(Var1), y = Freq, colour = Var2, group = Var2)) + geom_line(size = 1) +
xlab("R Vs T") + geom_point() +
scale_x_discrete(labels = function(x) str_wrap(x, width = 2)) +
ggtitle("Number of T Vs R - through the day") +
theme(plot.title=element_text(size=rel(1.2), lineheight = 1 ))
How do I remove the YMD data from this, because I want only the time and not the data in x-axis and the x-axis in the graph looks completely garbled.