1

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?

Community
  • 1
  • 1
Armenia22
  • 145
  • 5
  • 1
    `sym() ->These functions take strings as input and turn them into symbols`. You did not quote your dot, so this is no string. – Markus Jun 14 '19 at 08:26
  • Thanks Markus but same error comes back with the quoted version! – Armenia22 Jun 14 '19 at 08:29
  • 1
    This might be all wrong, but do you need to use `toString()` around the `.`? I have a hard time following the code without going through some of the example link. – larsoevlisen Jun 14 '19 at 08:31
  • Not helpful larsoevlisen. Again same error but many tanks for trying. The error is now from `rsme_train <-` onwards but it is the same error! – Armenia22 Jun 14 '19 at 08:34
  • i had this exact same question! do you know if this originates from here? blogs.rstudio.com/ai/posts/2018-06-25-sunspots-lstm – stats_noob Dec 29 '20 at 08:21

1 Answers1

2

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.

thie1e
  • 3,588
  • 22
  • 22
  • i had this exact same question! do you know if this originates from here? https://blogs.rstudio.com/ai/posts/2018-06-25-sunspots-lstm/ – stats_noob Dec 29 '20 at 08:20
  • there is a similar portion of code in the same tutorial that also doesnt work: coln <- colnames(compare_test)[4:ncol(compare_test)] cols <- map(coln, quo(sym(.))) rsme_test <- map_dbl(cols, function(col) rmse( compare_test, truth = value, estimate = !!col, na.rm = TRUE )) %>% mean() rsme_test – stats_noob Dec 29 '20 at 08:30