Dear All,
I am making my baby steps with tidymodels. When I run the code pasted below (taken from
so, it does not get more reputable than this!).
I get an error
x Bootstrap01: internal: Error: $ operator is invalid for atomic vectors
Does anybody know what is going wrong?
I have also installed the dev version of tidymodels, but no avail.
I also paste below is my sessionInfo().
Any help is very appreciated!
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 10 (buster)
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.3.5.so
locale:
[1] LC_CTYPE=en_GB.utf8 LC_NUMERIC=C
[3] LC_TIME=en_GB.utf8 LC_COLLATE=en_GB.utf8
[5] LC_MONETARY=en_GB.utf8 LC_MESSAGES=en_GB.utf8
[7] LC_PAPER=en_GB.utf8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] ranger_0.12.1 doParallel_1.0.15 iterators_1.0.12
[4] foreach_1.5.0 yardstick_0.0.6 workflows_0.1.1
[7] tune_0.0.1 rsample_0.0.6 recipes_0.1.10
[10] parsnip_0.0.5 infer_0.5.1 dials_0.0.5
[13] scales_1.1.0 broom_0.5.5 tidymodels_0.1.0.9000
[16] GGally_1.5.0 janitor_1.2.1 countrycode_1.1.1
[19] forcats_0.5.0 stringr_1.4.0 dplyr_0.8.99.9002
[22] purrr_0.3.3 readr_1.3.1 tidyr_1.0.2
[25] tibble_3.0.0 ggplot2_3.3.0 tidyverse_1.3.0
loaded via a namespace (and not attached):
[1] readxl_1.3.1 backports_1.1.5 tidytext_0.2.3
[4] plyr_1.8.6 igraph_1.2.5 splines_3.6.3
[7] crosstalk_1.1.0.1 listenv_0.8.0 SnowballC_0.7.0
[10] rstantools_2.0.0 inline_0.3.15 digest_0.6.25
[13] htmltools_0.4.0 rsconnect_0.8.16 fansi_0.4.1
[16] magrittr_1.5 globals_0.12.5 modelr_0.1.6
[19] gower_0.2.1 matrixStats_0.56.0 xts_0.12-0
[22] hardhat_0.1.2 prettyunits_1.1.1 colorspace_1.4-1
[25] rvest_0.3.5 xfun_0.12 haven_2.2.0
[28] callr_3.4.3 crayon_1.3.4 jsonlite_1.6.1
[31] lme4_1.1-21 survival_3.1-8 zoo_1.8-7
[34] glue_1.3.2 gtable_0.3.0 ipred_0.9-9
[37] pkgbuild_1.0.6 rstan_2.19.3 DBI_1.1.0
[40] miniUI_0.1.1.1 Rcpp_1.0.4 xtable_1.8-4
[43] GPfit_1.0-8 stats4_3.6.3 lava_1.6.7
[46] StanHeaders_2.19.2 prodlim_2019.11.13 DT_0.13
[49] htmlwidgets_1.5.1 httr_1.4.1 threejs_0.3.3
[52] RColorBrewer_1.1-2 ellipsis_0.3.0 farver_2.0.3
[55] pkgconfig_2.0.3 reshape_0.8.8 loo_2.2.0
[58] nnet_7.3-12 dbplyr_1.4.2 utf8_1.1.4
[61] labeling_0.3 tidyselect_1.0.0 rlang_0.4.5.9000
[64] DiceDesign_1.8-1 reshape2_1.4.3 later_1.0.0
[67] munsell_0.5.0 cellranger_1.1.0 tools_3.6.3
[70] cli_2.0.2 generics_0.0.2 ggridges_0.5.2
[73] fastmap_1.0.1 knitr_1.28 processx_3.4.2
[76] fs_1.3.2 future_1.16.0 nlme_3.1-143
[79] mime_0.9 rstanarm_2.19.3 xml2_1.2.2
[82] tokenizers_0.2.1 compiler_3.6.3 bayesplot_1.7.1
[85] shinythemes_1.1.2 rstudioapi_0.11 curl_4.3
[88] reprex_0.3.0 tidyposterior_0.0.2 lhs_1.0.1
[91] stringi_1.4.6 ps_1.3.2 lattice_0.20-38
[94] Matrix_1.2-18 nloptr_1.2.2.1 markdown_1.1
[97] shinyjs_1.1 vctrs_0.2.99.9010 pillar_1.4.3
[100] lifecycle_0.2.0 furrr_0.1.0 httpuv_1.5.2
[103] R6_2.4.1 promises_1.1.0 gridExtra_2.3
[106] janeaustenr_0.1.5 codetools_0.2-16 boot_1.3-23
[109] colourpicker_1.0 MASS_7.3-51.4 gtools_3.8.2
[112] assertthat_0.2.1 withr_2.1.2 shinystan_2.5.0
[115] hms_0.5.3 grid_3.6.3 rpart_4.1-15
[118] timeDate_3043.102 class_7.3-15 minqa_1.2.4
[121] snakecase_0.11.0 pROC_1.16.2 tidypredict_0.4.5
[124] shiny_1.4.0.2 lubridate_1.7.4 base64enc_0.1-3
[127] dygraphs_1.1.1.6
library(tidyverse)
library(countrycode)
library(janitor)
library(GGally)
library(tidymodels)
library(doParallel)
library(ranger)
### read the raw data
food_consumption <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-02-18/food_consumption.csv")
### get the data in shape for mining. "asia" is now the column you want to predict
food <- food_consumption %>%
select(-co2_emmission) %>%
pivot_wider(
names_from = food_category,
values_from = consumption
) %>%
clean_names() %>%
mutate(continent = countrycode(
country,
origin = "country.name",
destination = "continent"
)) %>%
mutate(asia = case_when(
continent == "Asia" ~ "Asia",
TRUE ~ "Other"
)) %>%
select(-country, -continent) %>%
mutate_if(is.character, factor)
gpl <- ggscatmat(food, columns = 1:11, color = "asia", alpha = 0.7)
ggsave( "matrix_plot.pdf", gpl, width=15, height=15)
set.seed(1234)
food_boot <- bootstraps(food, times = 30)
rf_spec <- rand_forest(
mode = "classification",
mtry = tune(),
trees = 1000,
min_n = tune()
) %>%
set_engine("ranger")
## cl <- makeCluster(2)
## registerDoParallel(cl)
rf_grid <- tune_grid(
asia ~ .,
model = rf_spec,
resamples = food_boot
)
## stopCluster(cl)