Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
268 views
in Technique[技术] by (71.8m points)

How can i substract 30 minutes to my timestamp R


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What is the class of your data? If your data is called df check class(df$column_name). If it is of class POSIXct you can do :

df$new_column <- df$column_name - 30*60

Or with lubridate :

df$new_column <- df$column_name - lubridate::minutes(30)

If the class is something different than POSIXct (eg - character) you need to first change it to POSIXct class before using the answer above. That can be done with

df$column_name <- as.POSIXct(df$column_name, tz = 'UTC')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...