Error in `stop_subscript` when rendering gitbook

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!

How can I delete this post? I figured out the problem.

Don’t delete it. If you can, share the solution to the problem so that somebody else that runs into it will have your help fixing it.

I had a markdown file with its own yaml hidden within a subfolder that did not have an underscore at the beginning of its file name, so bookdown was trying to append it to the end of the rendering but that threw an error.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.