r - 为什么我的时间序列中没有正确的变量?
问题描述
我正在尝试根据 csv 数据文件中的连续数字在 R 中进行一些预测。但是,在读取文件、删除文本列并使用 timeseries 函数后,我没有从行中获取值,也不知道它从哪里获取值。
我试图检查环境中的数据集,似乎对 115 个变量进行了 1 次观察,点击它会将我带到正确的数据,在那里我每月观察我正在研究的内容,但点击下一个蓝色小圆圈名称下拉列表,其中所有 115 个变量都被描述为具有 45 到 60 个级别的因子。在创建时间序列时,我尝试对它们进行矢量化,但这不起作用。
library(TTR)
library(forecast)
# then read in the dataset
tourism <- read.csv2("tourism.csv")
# extract relevant rows, vectorize them, and create a timeseries for each of the 3 groups
total <- tourism[3,]
total <- total[-1:-2]
total <- as.numeric(total)
foreig_tot <- tourism[4,]
foreig_tot <- foreig_tot[-1:-2]
foreig_tot <- as.numeric(foreig_tot)
norwegian <- tourism[5,]
norwegian <- norwegian[-1:-2]
norwegian <- as.numeric(norwegian)
total_ts <- ts(total, frequency = 12, start = c(2010,1))
foreig_tot_ts <- ts(foreig_tot, frequency = 12, start = c(2010,1))
norwegian_ts <- ts(norwegian, frequency = 12, start = c(2010,1))
创建时间序列时,我应该得到大约 95 000 到 150 000 的值,但我得到的值在 20 到 50 之间。
解决方案
推荐阅读
- android - 构建 APK - 片段 buildConfig.class 错误
- centos - 邮件 -r 选项被忽略
- javascript - React Native - 如何水平滑动卡片并给它们留出边距
- amazon-web-services - 如何在本地服务器上配置 AWS 角色?
- r - 比较两个数据框中的名称
- elasticsearch - Logstash 无法识别的国家/地区 VM 选项“UseParNewGC”
- python - 如何从列表中随机选择一个连续样本?
- reactjs - React - 如何为不同的 .map 数据数组设置状态?
- string - 无法将从输入对话框输入的字符串与 Groovy 中的不同字符串进行比较
- php - PHP我们一个字符串变量作为函数的参数