Skip to content
Prev 387175 / 398502 Next

Axis whitout all the row, that contains time

Hello,

Please always cc the r-help mailing list, this might be helpful to 
others in the future.

1. You have a data file using the continental Europe convention of 
marking the decimals with a comma, therefore you should read the data in 
with read.csv2:

the columns separator is the semi-colon: sep = ";"
the decimal point is comma: dec = ","
the default value for argument header = TRUE

Like this you are reading in the numeric data as strings, I will take 
care of that in the code but try read.csv.

2. You have 2 typos.

factorsAsStrings instead of stringsAsFactors. But unless you have a good 
reason to set this to TRUE, I suggest you do not. If it's just to plot 
the data, then don't.

The times format string is missing the percent sign "%" before the H.


2. Now the code. Note that I don't set stringsAsFactors = TRUE and that 
I replace the commas with periods in the 2nd instruction.
Also, aes(..., color = variable) already groups the lines, there is no 
need for group = variable.



liste_data_long <- melt(In_IL, id = "DateHeure")
liste_data_long$value <- sub(",", ".", liste_data_long$value)
liste_data_long$value <- as.numeric(liste_data_long$value)

library(ggplot2)

ggplot(liste_data_long, aes(x = DateHeure, y = value, color = variable)) +
   geom_line() +
   geom_point() +
   scale_x_datetime(date_breaks = "60 secs", date_labels = "%H:%M:%S")



Hope this helps,

Rui Barradas


?s 15:01 de 14/02/21, Informatique escreveu: