【问题标题】:Check if a variable is xts or data.frame检查变量是 xts 还是 data.frame
【发布时间】:2014-03-19 21:24:36
【问题描述】:

这个问题说明了一切......如果给定的函数参数是 xts 或数据帧类型,我想检查我的一个函数。我该怎么做?

【问题讨论】:

标签: r types dataframe xts


【解决方案1】:

一般做法是为这些类型的检查和转换添加is.smthas.smth 函数:

df <- data.frame()
xt <- xts()
is.data.frame(df)
[1] TRUE
is.data.frame(xt)
[1] FALSE
is.xts(df)
[1] FALSE
is.xts(xt)
[1] TRUE

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-24
    • 2020-01-30
    • 2021-03-17
    • 2018-11-26
    • 1970-01-01
    • 1970-01-01
    • 2019-12-19
    • 2010-12-19
    相关资源
    最近更新 更多