날짜없는 time

Published by onesixx on

https://departmentfortransport.github.io/R-cookbook/dates-times.html

string –> time

시각

R
> tt <- data.table(timeString = c("0:05:00","1:41:46","1:00:00","3:14:02","1:00:00"))
   timeString
1:    0:05:00
2:    1:41:46
3:    1:00:00
4:    3:14:02
5:    1:00:00
> tt[ , as.difftime(timeString, units="secs")]  # 클래스 difftime from base
Time differences in secs
[1]   300  6106  3600 11642  3600
> tt[ , as_hms(timeString)]                     # 클래스 difftime from hms   
00:05:00
01:41:46
01:00:00
03:14:02
01:00:00
> tt[ , as.period(as_hms(timeString))]          # 클래스 Period   from lubridate
[1] "5M 0S"      "1H 41M 46S" "1H 0M 0S"   "3H 14M 2S"  "1H 0M 0S"  


> tt[ , as.difftime(timeString, units="secs")] %>% sum() %>% as.numeric()
> tt[ , as_hms(timeString)]                    %>% sum() %>% as.numeric()  # 초 기준 
> tt[ , as.period(as_hms(timeString))]         %>% as.numeric(units="seconds") %>% sum()
[1] 25248

시간

R
> timeString <- "24:00:06"
> as.ITime(timeString)
[1] "00:00:00"
> as.difftime(timeString, units="secs")
Time difference of NA secs
> as_hms(timeString)
NA
Warning message:
Lossy cast from <character> to <hms> at position(s) 1 
> as.period(as_hms(timeString))
[1] NA
Warning message:
Lossy cast from <character> to <hms> at position(s) 1 
> tt[ , as.ITime(timeString)]            %>% sum() %>% as.numeric()  # 초 기준 
Error in tt[, as.ITime(timeString)] : incorrect number of dimensions
R

as.difftime

https://onesixx.com/lubridate/

hms

https://campus.datacamp.com/courses/working-with-dates-and-times-in-r/problems-in-practice?ex=5

 hh:mm:ss format

  • ‘difftime’ class를 기본
  • 자정부터 second의 numeric vector (digits.secs 옵션으로 micro secound까지 표현 가능)
R

cron

https://stackoverflow.com/questions/22659947/r-how-to-handle-times-without-dates

package chron requires extra work to add seconds, and time subtraction that results in negative values is no longer formatted as a time

R

fasttime

https://cran.r-project.org/web/packages/fasttime/fasttime.pdf

Fast Utility Function for Time Parsing and Conversion

연산에서 period vs. duration

https://itoner.tistory.com/11 [공돌이 일기]

“기간” period, duration, term

period
시작부터 결론까지의 시간의 길이
빙글 빙글 가거나 오거나, 반복있는 ‘시작과 끝’같은 이미지의 “기간”

duration
지속되는 동안 ‘이라는 뜻의 기간
endure는 “지속” during (~ 사이)을 이미지

term
“처음부터 결론까지의 시간 , 기간에 특히 공식적으로 정해진 기간
임기이나 계약 기간이나 징역 연수 등에 쓰임.
term의 어원은 ‘가장자리’ ‘경계’ ‘한계’의 의미에서 determine가 “경계를 명확하게 (de) 결정 ‘이라는 의미
term도”명확하게 정해진’이라는 의미를 담은 ‘기간’ 입니다. 

Duration vs. Period in r

R
R

한달 더하기

https://stackoverflow.com/questions/14169620/add-a-month-to-a-date

Function %m+% from lubridate adds one month without exceeding last day of the new month.

R
[1] "2012-02-29"
https://www.zeitverschiebung.net/en/

Time Interval

R
Categories: R Basic

onesixx

Blog Owner

guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x