【问题标题】:converting data into time series data将数据转换为时间序列数据
【发布时间】:2020-06-13 21:51:42
【问题描述】:

我尝试输入这些命令,但它不起作用...有人可以帮忙吗?

OPts <- read.csv(OILBRENT)

read.table 中的错误(文件 = 文件,标题 = 标题,sep = sep,quote = quote,: 'file' 必须是字符串或连接

OPts <- ts(OILBRENT, start = c(jun-87), end = c(Jan-20), frequency =12)

ts(OILBRENT, start = c(jun - 87), end = c(Jan - 20), frequency = 12) 中的错误: 找不到对象“君”

OPts <- ts(OILBRENT, start = c(jun-87, 1), end = c(Dec-19, 12), frequency =12)

ts(OILBRENT, start = c(jun - 87, 1), end = c(Dec - 19, 12), frequency = 12) 中的错误: 找不到对象“君”

【问题讨论】:

  • 请查看How to make a great R reproducible example,以修改您的问题,并从您的数据中提取更小的样本(查看?dput())。发布您的数据或没有数据的图像会使我们难以为您提供帮助!
  • 什么是U?此处不要使用俚语。
  • @fcm U 是 I 旁边的字母。鉴于这句话,它可能是一个错字...
  • 首先,您需要成功导入数据。完成该任务后,您需要找到 Jun。

标签: r time-series data-manipulation


【解决方案1】:

您似乎缺少一些引号。

read.csv 期望 character 指向文件或连接。如果您尝试读取当前工作目录中的文件,请尝试OPts &lt;- read.csv("OILBRENT")

两个ts 命令似乎都失败了,因为start 参数需要一个数字或一个数字向量。当你写start = c(jun-87) 时,R 将尝试找到一个对象jun,然后计算差值jun - 87。来自ts 的手册页:

  start: the time of the first observation.  Either a single number or
          a vector of two integers, which specify a natural time unit
          and a (1-based) number of samples into the time unit.  See
          the examples for the use of the second form.

【讨论】:

    猜你喜欢
    • 2019-06-16
    • 1970-01-01
    • 2021-05-02
    • 1970-01-01
    • 2023-01-25
    • 2021-09-23
    • 2020-03-14
    • 1970-01-01
    相关资源
    最近更新 更多