无法删除R中某些库的警告和消息
我无法理解这些消息来自哪个库:无法删除R中某些库的警告和消息,r,suppress,R,Suppress,我无法理解这些消息来自哪个库: Warning messages: 1: In if (!(tclass %in% c("yearmon", "yearqtr"))) lubridate::tz(ret) <- tzone : the condition has length > 1 and only the first element will be used 2: In if (!(tclass %in% c("yearmon", "yearqtr"))) lubridate
Warning messages:
1: In if (!(tclass %in% c("yearmon", "yearqtr"))) lubridate::tz(ret) <- tzone :
the condition has length > 1 and only the first element will be used
2: In if (!(tclass %in% c("yearmon", "yearqtr"))) lubridate::tz(ret) <- tzone :
the condition has length > 1 and only the first element will be used
我已经试着压制lubridate和zoo了。还是没有变化
请建议我应该如何抑制上述消息
Dataframe如下所示:
1499889600,18.71832
1499893200, 19.02870
1499896800, 18.91708
1499900400, 18.80855
1499904000, 19.04631
1499907600, 18.89747
1499911200, 18.69003
1499914800, 18.98538
1499918400, 18.87732
1499922000, 18.69314
1499925600, 18.99397
1499929200, 18.77869
1499932800, 18.68454
1499936400, 18.98039
1499940000, 18.88998
1499943600, 18.71440
1499947200, 18.98789
1499950800, 18.86854
1499954400, 18.69711
1499958000, 18.91687
1499961600, 18.89083
1499965200, 18.82566
1499968800, 19.00667
1499972400, 18.87633
1499976000, 18.72960
1499979600, 19.04492
1499983200, 18.91356
1499986800, 18.83017
1499990400, 19.02865
1499994000, 18.88282
1499997600, 18.70087
1500001200, 19.06607
1500004800, 18.80885
1500008400, 18.61242
1500012000, 18.94070
1500015600, 18.82240
1500019200, 18.68274
1500022800, 18.97367
1500026400, 18.79754
1500030000, 18.72475
1500033600, 18.94517
1500037200, 18.93362
1500040800, 18.69782
1500044400, 19.02091
1500048000, 18.83109
1500051600, 18.74415
1500055200, 18.89581
1500058800, 18.90286
代码:
# Use as_datetime to convert from numeric time stamps to date-times
dataframe <- dataframe %>%
mutate(timestamp = as_datetime(timestamp))
# Setup your ts object
ts_frequency <- 24
start <- 1
tk_ts_dataframe <- tk_ts(dataframe, start = start, freq = ts_frequency, silent = TRUE)
# Arima model
fit <- auto.arima(tk_ts_dataframe, trace = TRUE, stepwise = FALSE)
# Forecast
forecast_duration <- 10
fc <- forecast(fit, h = forecast_duration)
# Perform sweep
final <- sw_sweep(fc, timekit_idx = TRUE)
final
它似乎不是来自任何包,而是来自if语句条件的逻辑。R试图告诉您tclass不是您可能怀疑或可能不怀疑的原子值,而是值的列表/向量。因此,不要查看向量/列表中的所有值以放入IF条件,它只考虑向量/列表的第一个元素。 解决方案:确保tclass是一个原子值以消除警告,如果您知道它是一个向量,并且您不介意它是否使用第一个值,那么您就可以了
另外,若要同时消除警告消息,请使用选项WARN=-1您需要修复代码问题,而不是抑制警告。您能从何处得知这一点吗。我没有在我的代码中使用过这种if?首先向我解释一下tclass到底应该是什么?我认为tclass是timeseries。现在基本上我正在timeseries数据上应用ARIMA。最初,我有一个数据帧,其中历元时间为row.name,值在一列中。我转换成的这个数据帧:tk_tsts_df,start=1,freq=ts_frequency,silent=TRUE timeseries对象,arima可以应用在这个对象上。现在,我看到了您要做的事情,但是,请将初始化tclass的代码发送给我,以便我们可以尝试修复该问题并删除警告。您仍然没有向我显示tclass的来源。我需要知道这一点,因为tclass是if声明中的主要问题。不,在你的if语句中哪里提到了你的数据帧,所以我不需要知道
# Use as_datetime to convert from numeric time stamps to date-times
dataframe <- dataframe %>%
mutate(timestamp = as_datetime(timestamp))
# Setup your ts object
ts_frequency <- 24
start <- 1
tk_ts_dataframe <- tk_ts(dataframe, start = start, freq = ts_frequency, silent = TRUE)
# Arima model
fit <- auto.arima(tk_ts_dataframe, trace = TRUE, stepwise = FALSE)
# Forecast
forecast_duration <- 10
fc <- forecast(fit, h = forecast_duration)
# Perform sweep
final <- sw_sweep(fc, timekit_idx = TRUE)
final