[英]How to separate Hours minutes and seconds from data using tidyr Package in R language?
Here is the data i had 这是我的数据
temp time_hour
1 37.04 2013-01-01 05:30:00
2 37.04 2013-01-01 06:30:00
3 37.94 2013-01-01 07:30:00
4 37.94 2013-01-01 08:30:00
5 37.94 2013-01-01 09:30:00
Now i need to separate the time_hour column to "date","month","year" and also to "Hours","minutes","seconds" using tidyr package in R programming languages. 现在,我需要使用R编程语言中的tidyr包将time_hour列分隔为“ date”,“ month”,“ year”以及“ Hours”,“ minutes”,“ seconds” 。 I used separate variables to separate date, month, year .
我使用单独的变量来分隔日期,月份和年份 。 i don't know how to separate time like hours, minutes, seconds .
我不知道如何分隔时间,例如小时,分钟,秒 。 Thanks in advance...
提前致谢...
We can use separate
我们可以
separate
使用
library(tidyr)
df1 %>%
separate(time_hour, into = c("year", "month", "day", "hour", "minutes", "seconds"))
# temp year month day hour minutes seconds
#1 37.04 2013 01 01 05 30 00
#2 37.04 2013 01 01 06 30 00
#3 37.94 2013 01 01 07 30 00
#4 37.94 2013 01 01 08 30 00
#5 37.94 2013 01 01 09 30 00
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.