所以,这是我在包括时间序列部分之前所做的完整代码。
library(tidyverse)
library(xts)
library(fpp)
library(astsa)
library(DT)
library(dygraphs)
library(lubridate)
library(readxl)
Aust_Beer_Production <- read_excel("D:/Working Directory/monthly-beer-production-in-austr.xlsx")
Aust_Beer_Production2 <- as.data.frame(Aust_Beer_Production, stringsAsFactors = F)
names(Aust_Beer_Production2)[2] <- "MegaLiters_Monthly"
Aust_Beer_Production3 <- Aust_Beer_Production2 %>%
mutate(Revenue = MegaLiters_Monthly * 1000 * 15)
有人知道如何防止此事件在我的R Markdown文件中弹出:
## Warning in data.matrix(data): NAs introduced by coercion
我正在将数据集转换为ts
Aust_Beer_TS <- ts(Aust_Beer_Production2, frequency = 12, start = c(1956,1), end = c(1990, 12))
我应该尝试通过lubridate进行转换吗?在以前的尝试中,我尝试了
Aust_Beer_Production3$Month <- as.Date(Aust_Beer_Production3$Month, "yearmon")
但显然没有任何改变
我如何强行删除被强制执行的NA并纠正错误?