martijnvanattekum / learncpp_makebook

Creates an offline book from the learncpp.com website
1 stars 0 forks source link

Out of bound error! #1

Open abhayhm opened 1 year ago

abhayhm commented 1 year ago

Error message:

[1] "** Starting creation of index table (STEP1)" Error in map(): ℹ In index: 1. Caused by error in .[[1]]: ! subscript out of bounds

Error is in line 77:

tables <- map(table_xpaths, ~homepage %>% read_html() %>% html_nodes(xpath = .x) %>% html_table(fill = TRUE, header = FALSE) %>% .[[1]] %>% #take first element of list .[-1,]) #remove header

dstromberg commented 1 month ago

I'm getting this same error on Ubuntu 22.04.4 LTS "Jammy".

I installed using:

sudo apt install r-cran-littler
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libfontconfig1-dev
sudo apt-get install libharfbuzz-dev libfribidi-dev
sudo apt-get install libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
echo 'install.packages("tidyverse")' | r
echo 'install.packages("rvest")' | r
echo 'install.packages("tableHTML")' | r

The full error and command I ran to get it, looks like:

$ Rscript learncpp_makebook.R
below cmd output started 2024 Wed Aug 14 12:53:21 PM PDT
-- Attaching core tidyverse packages ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ tidyverse 2.0.0 --
v dplyr     1.1.4     v readr     2.1.5
v forcats   1.0.0     v stringr   1.5.1
v ggplot2   3.5.1     v tibble    3.2.1
v lubridate 1.9.3     v tidyr     1.3.1
v purrr     1.0.2
-- Conflicts ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()
i Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Attaching package: 'rvest'

The following object is masked from 'package:readr':

    guess_encoding

[1] "** Starting creation of index table (STEP1)"
Error in `map()`:
i In index: 1.
Caused by error in `.[[1]]`:
! subscript out of bounds
Backtrace:
     x
  1. +-purrr::map(...)
  2. | \-purrr:::map_("list", .x, .f, ..., .progress = .progress)
  3. |   +-purrr:::with_indexed_errors(...)
  4. |   | \-base::withCallingHandlers(...)
  5. |   +-purrr:::call_with_cleanup(...)
  6. |   \-global .f(.x[[i]], ...)
  7. |     \-... %>% .[-1, ]
  8. \-base::.handleSimpleError(`<fn>`, "subscript out of bounds", base::quote(.[[1]]))
  9.   \-purrr (local) h(simpleError(msg, call))
 10.     \-cli::cli_abort(...)
 11.       \-rlang::abort(...)
Execution halted
above cmd output done    2024 Wed Aug 14 12:53:23 PM PDT

I'd love to have an epub of learncpp! Thanks for your valuable time.

PS: I haven't even written a "hello world" in R.