【问题标题】:how to create time slot vector from two numeric vectors in R [duplicate]如何从R中的两个数值向量创建时隙向量[重复]
【发布时间】:2017-01-03 05:59:55
【问题描述】:

我已将两个向量存储为

hrs <- sample(0:23,500,replace=T)
mins<- sample(0:59,500,replace=T)

所以我的问题是我们可以将这两个向量以HH:MM 格式存储在 R 语言中的单个向量中吗?

【问题讨论】:

    标签: r


    【解决方案1】:

    我们可以使用paste

    paste(hrs, mins, sep=":")
    

    如果我们需要HH:MM 格式,请使用sprintf

    sprintf("%02d:%02d", hrs, mins)
    

    【讨论】:

    • 非常感谢
    猜你喜欢
    • 2018-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多