Hello, i'm using Rstudio from a few day, and i have some information in a CVS file, take every five second, format of the time is HH:MM:SS. I use the hour on the X axis, but i don't want having all the time print. For example only every 10 values. I think it will be possible with scale_x_datetime(breaks = date_breaks(XXX) but i don't understand how select every 20 s. Thank's for your help Fran?ois-marie BILLARD -- Informatique <informatique at billard-francois-marie.eu>
With a dat.frame "mydata" create a new variable mydata$num mydata$num <- 1:nrow(mydata) new_data <- subset(mydata, num == 10) plot using new_data On Fri, 12 Feb 2021 at 10:35, Informatique < informatique at billard-francois-marie.eu> wrote:> Hello, > > i'm using Rstudio from a few day, and i have some information in a CVS > file, take every five second, format of the time is HH:MM:SS. > I use the hour on the X axis, but i don't want having all the time print. > For example only every 10 values. > > I think it will be possible with scale_x_datetime(breaks > date_breaks(XXX) > > but i don't understand how select every 20 s. > > Thank's for your help > > Fran?ois-marie BILLARD > -- > Informatique <informatique at billard-francois-marie.eu> > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- John Kane Kingston ON Canada [[alternative HTML version deleted]]
Hello, In order to select every 20 s, set the date_breaks = "20 secs", not the breaks. The axis labels are also formatted, with date_labels, standard datetime format strings are used for this. And rotated, not part of the question. # Create some data set.seed(2021) time <- seq(as.POSIXct("2021-02-11"), as.POSIXct("2021-02-11 00:29:59"), by = "1 secs") y <- cumsum(rnorm(length(time))) df1 <- data.frame(time, y) # Plot the data library(ggplot2) ggplot(df1, aes(time, y)) + geom_line() + scale_x_datetime(date_breaks = "20 secs", date_labels = "%M:%S") + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1, size = 5)) Hope this helps, Rui Barradas ?s 15:05 de 12/02/21, Informatique escreveu:> Hello, > > i'm using Rstudio from a few day, and i have some information in a CVS file, take every five second, format of the time is HH:MM:SS. > I use the hour on the X axis, but i don't want having all the time print. For example only every 10 values. > > I think it will be possible with scale_x_datetime(breaks = date_breaks(XXX) > > but i don't understand how select every 20 s. > > Thank's for your help > > Fran?ois-marie BILLARD >