business-science / tidyquant

Bringing financial analysis to the tidyverse
https://business-science.github.io/tidyquant/
Other
855 stars 175 forks source link

Warning: `type_convert()` only converts columns of type 'character'. #202

Open mdancho84 opened 3 years ago

mdancho84 commented 3 years ago

Warning from various mapped functions. Looks to be not an issue, but annoying.

library(tidyquant)
library(tidyverse)

Ra <- c("AAPL", "GOOG", "NFLX") %>%
    tq_get(get  = "stock.prices",
           from = "2010-01-01",
           to   = "2015-12-31") %>%
    group_by(symbol) %>%
    tq_transmute(select     = adjusted, 
                 mutate_fun = periodReturn, 
                 period     = "monthly", 
                 col_rename = "Ra")
#> Registered S3 method overwritten by 'tune':
#>   method                   from   
#>   required_pkgs.model_spec parsnip
#> Warning: `type_convert()` only converts columns of type 'character'.
#> - `df` has no columns of type 'character'
#> Warning: `type_convert()` only converts columns of type 'character'.
#> - `df` has no columns of type 'character'

#> Warning: `type_convert()` only converts columns of type 'character'.
#> - `df` has no columns of type 'character'

#> Warning: `type_convert()` only converts columns of type 'character'.
#> - `df` has no columns of type 'character'

#> Warning: `type_convert()` only converts columns of type 'character'.
#> - `df` has no columns of type 'character'

#> Warning: `type_convert()` only converts columns of type 'character'.
#> - `df` has no columns of type 'character'
Ra
#> # A tibble: 216 x 3
#> # Groups:   symbol [3]
#>    symbol date            Ra
#>    <chr>  <date>       <dbl>
#>  1 AAPL   2010-01-29 -0.103 
#>  2 AAPL   2010-02-26  0.0654
#>  3 AAPL   2010-03-31  0.148 
#>  4 AAPL   2010-04-30  0.111 
#>  5 AAPL   2010-05-28 -0.0161
#>  6 AAPL   2010-06-30 -0.0208
#>  7 AAPL   2010-07-30  0.0227
#>  8 AAPL   2010-08-31 -0.0550
#>  9 AAPL   2010-09-30  0.167 
#> 10 AAPL   2010-10-29  0.0607
#> # ... with 206 more rows

Created on 2021-08-15 by the reprex package (v2.0.0)

jarodmeng commented 3 years ago

I bumped into this and those warnings look much more scary than they really are.

I think this is related to tidyverse/readr#1020 and tidyverse/readr#1019. The warnings pop up in tk_tbl.zoo() in the timetk package. It should be a simple fix there to check the input fed into readr::type_convert(). I will create a PR in timetk.