Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failing to compile the book #608

Closed
alperyilmaz opened this issue Sep 11, 2017 · 11 comments
Closed

failing to compile the book #608

alperyilmaz opened this issue Sep 11, 2017 · 11 comments

Comments

@alperyilmaz
Copy link

I cloned 0f956d6 from this repo and when I try to compile the book with bookdown:::serve_book(), in both Windows and Linux, I got the same error.

The error message was:

Quitting from lines 144-151 (model-building.Rmd) 
Error in overscope_eval_next(overscope, expr) : object 'G' not found
Calls: local ... lst_quos -> eval_tidy -> overscope_eval_next -> .Call

Execution halted
Error in Rscript_render(f, render_args, render_meta) : 
  Failed to compile model-building.Rmd

What am I doing wrong here?

> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.4.1  backports_1.1.0 bookdown_0.5    magrittr_1.5    rprojroot_1.2   htmltools_0.3.6
 [7] tools_3.4.1     rstudioapi_0.7  yaml_2.1.14     Rcpp_0.12.12    stringi_1.1.5   rmarkdown_1.6  
[13] knitr_1.17      stringr_1.2.0   digest_0.6.12   evaluate_0.10.1
@Facottons
Copy link

I got the PDF, after some errors, some very similar to yours. In my case the error messages was not very clear about the error itself and about the error line. So my advice is to check the root folder after a error. If you look closely you have strings.Rmd and strings.knit.Rmd (or something like that) files in the folder.
Open both files, side by side.
Go to last line in strings.knit.Rmd (or something like that) and see which code chunk was the root of your problem.
After that, add eval = FALSE in strings.Rmd {r} and rerun knit.
Repeat this process until you will have the PDF rendered book.

Of course this in some cases could not be the best, or even the correct solution. But it worked for me, the only trick that works, after many tries, uploading packages and Latex.

@alperyilmaz
Copy link
Author

The method suggested by @Facottons can be used to render the book in case of errors I guess. But I was trying to pinpoint the problem although I'm not good at debugging R. Based on the discussion regarding how ordered factors handled, I tried to verify that was indeed the problem.

I changed line 121 in model-building.Rmd into this (color, cut and clarity are wrapped around as.numeric():

mod_diamond2 <- lm(lprice ~ lcarat + as.numeric(color) + as.numeric(cut) + as.numeric(clarity), data = diamonds2)

and it still I get error in line 128. The code below cannot accomadete the model well.

grid <- diamonds2 %>% 
  data_grid(cut, .model = mod_diamond2)

@alperyilmaz
Copy link
Author

Forget to mention, if I comment out the chunk (or convert into a regular code block) between lines 126-134, the book compiles without problems.

@rezabakhtiari
Copy link

one maybe naive question, because I get also the same error of "lines 144-151 (model-building.Rmd) ". How can I completely comment out this file (model-building.Rmd) ? I am interested in other parts of the more, so I can live without this!

Thanks!

@Ranae
Copy link
Contributor

Ranae commented Jan 10, 2018

I also had trouble compiling the book, but only as a pdf. Adding always_allow_html: yes, was suggested, but did not seem to do anything at all. In the end, I compiled most of the book by doing the following two things:

  1. Got around the model-building problem by making this replacement as suggested here:

grid <- diamonds2 %>%
data_grid(cut, .model = mod_diamond2) %>%
add_predictions(mod_diamond2)

replaced with this:

grid <- diamonds2 %>%
data_grid(cut, lcarat = -0.515, color = "G", clarity = "SI1") %>%
add_predictions(mod_diamond2)

  1. Left out strings.Rmd and rmarkdown-formats.Rmd by deleting them in the _bookdown.yml file - these had complaints about not being rendered as html.

@eddelbuettel
Copy link
Contributor

So as a follow-up, on Ubuntu I needed to

  • set eval=FALSE for all chunks with str_view() and str_view_all() in the strings.Rmd file
  • set eval=FALSE on the one chunk with leaflet in rmarkdown-formats.Rmd

in addition to the ggplot2 fix shown by @Ranae to produce a 408 page pdf.

@jrneal1
Copy link

jrneal1 commented Mar 27, 2018

I'll try to help before I ask for help. For those of you having issues with the strings.Rmd file, you should run the following lines:

install.packages("webshot")
library(webshot)
webshot::install_phantomjs()

That should get the strings chapter to compile without error. Additionally, you should look at the packages listed under the Imports section of the DESCRIPTION file and be sure those are installed as well.

Having said that, I could use some help with the following error:

Output created: _book/_main.pdf
Error in tools::file_path_as_absolute(output_file) : 
  file '_book/_main.pdf' does not exist

The _book directory exists because other files are in there, however the pdf is missing.

EDIT: I finally have a complete PDF. For reference, I'm using MiKTeX 2.9 and I had to run the mo.exe file from the bin directory of the installation. This will launch MiKTex Options. From the general tab, select Yes from the drop down for "Install missing packages on-the-fly".

@zoe-xanthellae
Copy link

zoe-xanthellae commented Apr 5, 2018

@jrneal1 @alperyilmaz Great to hear you were able to create a complete pdf! Would you be willing to share your knitted pdf version with others? I only ask because I am an R novice and not familiar with the code to create a pdf from markdown, but would like to be able to highlight/annotate on a personal pdf copy to help me learn.

@jrneal1
Copy link

jrneal1 commented May 18, 2018

@zoe-xanthellae I would prefer to teach you how to fish rather than give you a fish. At least make a stab at it and post any issues.

@Ranae
Copy link
Contributor

Ranae commented May 18, 2018

I totally agree with @jrneal1 that it is not great to just be giving out fish, but since this book is what actually teaches fishing in the first place, I'm happy to link to my copy here.

But please do note that this version is missing the chapter on Strings and, ironically, R Markdown Format.

@zoe-xanthellae
Copy link

Thanks @Ranae, much appreciated!

@hadley hadley closed this as completed Jun 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants