Bookdown related problem in R markdown

Hi all,
I am facing a problem to work on bookdown in R markdown:
When I am trying to run this chunk:
Read the help file of the function bookdown::render_book

bookdown::render_book("index.Rmd", "bookdown::pdf_book")
bookdown::render_book("intro.Rmd", "bookdown::pdf_book")
bookdown::render_book("graphics.Rmd", "bookdown::pdf_book")
bookdown::render_book("functions.Rmd", "bookdown::pdf_book")

This error comes out
Error in bookdown::render_book("intro.Rmd", "bookdown::pdf_book") : The file _main.Rmd exists. Please delete it if it was automatically generated. If you are sure it can be safely overwritten or deleted, please set the option 'delete_merged_file' to true in _bookdown.yml.

Additionally, while knitting this error output is found:

Error in render_book(input_file, output_format, envir = envir, preview = TRUE) :
The file _main.Rmd exists. Please delete it if it was automatically generated. If you are sure it can be safely overwritten or deleted, please set the option 'delete_merged_file' to true in _bookdown.yml.
Calls: -> -> render_book
Execution halted

How to solve these issues?
Thanks in advance.

Did you create _main.Rmd? Have you opened it to make sure you know whether you need it? Have you deleted it and tried again?

I have deleted the '_main. Rmd' file several times and tried, it comes again while I go for knitting.
Please find the screenshot attached.
Thanks.

Bookdown relies on rmarkdown. Both render Rmd files. As such, _main.Rmd will exist already by the time you attempt to use bookdown. I’m not sure how you could work around this, but I also don’t understand why you are trying to render a book from inside Rmarkdown.

What are you trying to accomplish? Perhaps there is an easy alternative to this workflow.

Thanks for your feedback. Actually, I am trying to complile the rmd files (the chapters) into a book as a task for my Data Management (R) graduate class project for this semester.
Previously, when I created this project, added individual chapters (rmd files named as Introuction, Graphics, ggplots etc.) and tried to compile, it worked but a few weeks later I found errors.
I don't know why it happened or if I did anything wrong with R? I am actually a beginner and thus really fumbling around on this issue.

One question from your screenshot :
Are you calling render_book() in a chunk from inside your bookdown project you'll build ?

I am really not sure sure you can have a bookdown you will render with render_book that will itself call render_book.

Could it be what is happening ?

Yes, it looks like you are trying to give instructions for how to build the book, but those instructions actually run when you build your book.

Actually, I have created several chapters (as individual rmd files) and added them to the book as I followed instructions from my friend. To check if the blank draft works I knitted it and it worked but weeks later when I tried it again I could not generate pdf book.

Your friends instructions are not correct.

What you should do is download the minimal demo book and open the project file. Uncomment the PDF line if you want a pdf. Click “build book” in the interface to try it out.

Then, to add your own content, all you need to do is add your own Rmd files. No need to modify commands or add lines of code. They will be found and added automatically. They will be added in alphabetical order, so you might want to put numbers at the beginnings of the names in order to get them in the order you want. Hope that helps.

2 Likes

Thanks a lot for the instruction.

1 Like

Perhaps you did not specify the file to link to - you just specified {r.... }

-here is an example

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.