how can transform a data.frame with factor in the first coloumn to datatype : I have a question about format a column to make a ggplot understand like a datatype.

I have a variable who I called "dat1". 
dat1 is a matrix made of a characters

    dat1 <- "2017-07-14 18:00:00", "2017-07-14 19:00:00","2017-07-14 20:00:00","2017-07-14 21:00:00", "2017-07-14 22:00:00", "2017-07-14 23:00:00"
    dat1=as.matrix(dat1)

    > class(dat1)
     "matrix"

    > class(dat1[,1])
     "character"

"mean_hour" is another variable, in that case is a matrix made of numeric type
 

    mean_hour <- c(132,134,432,233,564,345)
    mean_hour=as.matrix(mean_hour)

    > class(mean_hour)
    [1] "matrix"
    
    > class(mean_hour[,1])
    [1] "numeric"


Now I make a data.frame with dat1 and mean_hour:

    med_horaria_plot <- data.frame(dat1,mean_hour)

This data.frame stayed this way:

    > med_horaria_plot

                 dat1                     mean_hour
                 1 2017-07-14 18:00:00       132
                 2 2017-07-14 19:00:00       134
                 3 2017-07-14 20:00:00       432
                 4 2017-07-14 21:00:00       233
                 5 2017-07-14 22:00:00       564
                 6 2017-07-14 23:00:00       345

    > class(med_horaria_plot[,1])
    [1] "factor"
    
    > class(med_horaria_plot[,2])
    [1] "numeric"
    
    > class(med_horaria_plot)
    [1] "data.frame"

In fact, in my database this data.frame is much larger.
Whey I plot in ggplot the dates on the x-axis are all superimposed

How can I change a type os a columns of this data.frame for ggplot understanding this like a datatype and then choose the hours I want on the plot in order to avoid overlaps
