R语言 小程序

时间:2024-04-15 13:50:42
x<-sample(1:11)
x

日期和时间

###Data and Time###

> data_time <- data.frame(data = c("2015-06-01", "2016-01-01"), time = c("13:34", "07:15"))
>  
> data_time
        data  time
1 2015-06-01 13:34
2 2016-01-01 07:15

> data_time$c <- as.POSIXct(paste(data_time$data, data_time$time), format = "%Y-%m-%d  %H:%M")
> data_time
        data  time                   c
1 2015-06-01 13:34 2015-06-01 13:34:00
2 2016-01-01 07:15 2016-01-01 07:15:00
> format(data_time$c, "%Y-%m %H")
[1] "2015-06 13" "2016-01 07"
a<-1:100
sample(a,3)
sample(1:3,length(a),replace=T,prob=c(0.2,0.5,0.3))

typeof(now)
class(now)
a<-unclass(now)
a
b<-a-1395057600
b

[^LaTeX]

\[E=mc^2 \]