How to specify the schedule of the day and the calendar date in R

I'm sorry to come here after you burned hours on the Internet on this simplified matter.

I have several data sets to build in R, each of which consists of two data columns: time, date. I am using R 2.11.0 on a Windows computer through Rgui.

Time is the "time of day" when an event is observed. As an example, it is recognized as:

Factor w/ 87 levels "5:53","5:54",..: 84 85 85 85 86 ...

Date of calendar date recognized as:

Class 'Date'  num [1:730] 13879 13880 13881 13882 13883 ...

The time values ​​are recorded in the format of a 24-hour clock, h: mm or hh: mm. Date values ​​are displayed yyyy-mm-dd.

I want to calculate the time (y axis) compared to the date (x axis).

Using

plot(date,time)

, y ( 0 90), , . X , .

? R " ", ""? , .

(date + time) R . , , .

, ( ).

+3
3

, y . ticksAt , - .

Data <- data.frame(date=Sys.Date()+1:10,time=paste(5,41:50,sep=":"))
with(Data, plot(date,time,yaxt="n"))
ticksAt <- c(1,3,5,7,9)
axis(2, at=ticksAt, labels=as.character(Data$time)[ticksAt])

?plot.zoo , , . ?par .

+1

ts timeSeries - .
Related

0

, : Date "dt", - "tm":

 x <- paste(as.character(dt[1:2]), as.character(tm))
 strptime(x, "%Y-%m-%d %H:%M")
## [1] "2008-01-01 05:53:00" "2008-01-02 05:54:00"
class(strptime(x, "%Y-%m-%d %H:%M"))
##  [1] "POSIXt"  "POSIXlt"
0
source

Source: https://habr.com/ru/post/1778680/


All Articles