It took me a while to get this code working to create a template tibble a while ago while using earlier versions of dplyr. Eventually I had to settle in using the deprecated funs, as I couldn't get list and/or ~ to work.
I updated the dplyr 0.8.2 yesterday and the code no longer works - error message is "could not find column 2013/14" (or similar). Can anybody help in getting the code working?
library(dplyr)
yrsToInclude = c("2013/14", "2014/15", "2015/16", "2016/17", "2017/18")
tibble(
Pos = seq_len(10),
Provider = NA_character_
) %>%
mutate_at(yrsToInclude, funs(1 * NA))
This is the tibble that's produced in 0.8.1:
# A tibble: 10 x 7
Pos Provider `2013/14` `2014/15` `2015/16` `2016/17` `2017/18`
<int> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 <NA> NA NA NA NA NA
2 2 <NA> NA NA NA NA NA
3 3 <NA> NA NA NA NA NA
4 4 <NA> NA NA NA NA NA
5 5 <NA> NA NA NA NA NA
6 6 <NA> NA NA NA NA NA
7 7 <NA> NA NA NA NA NA
8 8 <NA> NA NA NA NA NA
9 9 <NA> NA NA NA NA NA
10 10 <NA> NA NA NA NA NA