On Tue, 20 Nov 2018, Knut Krueger writes: > I have an dataframe from with a given time format: > > "23:01:19" > > to change some given data: > > x=data.frame > ("Y"=c(1:5),"TIME"=c("23:01:18","23:01:18","23:01:18","23:01:18","23:01:18")) > > I need to change the time increasing in seconds > > x=data.frame > ("Y"=c(1:5),"TIME"=c("23:01:18","23:01:19","23:01:20","23:01:21","23:01:22")) > > > Is it possible without any additional package ? > > > Kind Regards Knut >
Like so? start <- "23:01:18" Y <- 1:5 tmp <- as.POSIXct(paste(Sys.Date(), start)) tmp <- tmp + seq(from = 0, length.out = length(Y)) format(tmp, "%H:%M:%S") ## [1] "23:01:18" "23:01:19" "23:01:20" "23:01:21" "23:01:22" data.frame(Y, TIME = format(tmp, "%H:%M:%S")) -- Enrico Schumann Lucerne, Switzerland http://enricoschumann.net ______________________________________________ R-help@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.