Getting error message while calculating rmse in a time series analysis

五迷三道 提交于 2021-02-10 19:32:36

问题


I am trying to replicate this example of time series analysis in R using Keras (see Here) and unfortunately I am receiving error message while computing first average rmes

coln <- colnames(compare_train)[4:ncol(compare_train)]
cols <- map(coln, quo(sym(.)))
rsme_train <-
  map_dbl(cols, function(col)
    rmse(
      compare_train,
      truth = value,
      estimate = !!col,
      na.rm = TRUE
    )) %>% mean()

rsme_train

Error message:

Error in is_symbol(x) : object '.' not found

There are some helpful comments at the bottom of the post but new version of dplyr doesn't help really. Any suggestion how to get around this?


回答1:


I stumbled upon the same problem, so here's a solution that is close to the original code.

The transformation for cols is not necessary, because !! works with the character vector already. You can change the code to

coln <- colnames(compare_train)[4:ncol(compare_train)]
rsme_train <-
    map_df(coln, function(col)
        rmse(
            compare_train,
            truth = value,
            estimate = !!col,
            na.rm = TRUE
        )) %>% 
    pull(.estimate) %>%
    mean()

rsme_train

You might also want to check for updates of tidyverse, just to be sure.



来源:https://stackoverflow.com/questions/56594095/getting-error-message-while-calculating-rmse-in-a-time-series-analysis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!