Hi, I keep getting the error below when trying to render a gitbook with bookdown.
Error in `stop_subscript()`:
! Can't subset columns that don't exist.
x Column `1` doesn't exist.
Backtrace:
1. global format_data(...)
5. dplyr:::select.data.frame(., all_of(var))
6. tidyselect::eval_select(expr(c(...)), .data)
7. tidyselect:::eval_select_impl(...)
16. tidyselect:::vars_select_eval(...)
...
23. tidyselect:::chr_as_locations(x, vars, call = call)
24. vctrs::vec_as_location(x, n = length(vars), names = vars)
25. vctrs `<fn>`()
26. vctrs:::stop_subscript_oob(...)
27. vctrs:::stop_subscript(...)
The format_data function is below:
format_data <- function(data, var){
data %>%
select(as.character(var)) %>%
unnest(as.character(var))
}
data
would be a tibble with multiple nested tibbles within it. var
is a 20x1 tibble with the specific column names I want to pull from data
.
formatted_weighted_data <- list()
# loop through each main column name that is nested in weighted_data, and create separate unnested datasets
for(i in 1:nrow(column_names_relocated)){
formatted_weighted_data[[i]] <- format_data(weighted_data, column_names_relocated[i, 1])
}
I can knit a markdown file fine, but I am not sure what the error message above is trying to tell me when rendering a gitbook.
Thanks for the help!