There's too little information to tell. Can you try to answer the following questions?
- What OS are you using, which version of R and RStudio?
- Have you ever used knit in the time window between when you generated the PDF until you deleted it?
- Can you run through the sequence of chunks without crashing, starting with an empty global environment?
- What do you mean by 'crashing' (Error during knitting, no response, session termination)?
Assuming that your answer to 2. and 3. is 'no', you've likely added some changes that rely on some values being present in the global environment. You should look at the log to find out where the error occurs.
Assuming you answered yes to 3., and you are using Linux, perhaps there's a discrepancy between the library path used in the R Session and that used during knitting?
Assuming your answer to 4. is that the R Session is terminated and restarted, try to answer the following questions:
- Are you using Rcpp or Fortran code?
- Are you using parallel processing?
- Are you doing something that might consume too much system memory?
If you answered yes to 1., the crash might be related to memory management. For example, I once forgot to actually assign an address to a pointer in one of my Rcpp functions, resulting in the session being terminated upon calling it from within R.
Points 2. and 3. seem improbable to me, but it can't hurt to make sure.
Finally, if none of these questions helped to identify the issue, please attach some additional details about the packages you are using, and a rough description of what your code is supposed to be doing.
Edit: Also note that deleting the PDF wouldn't cause such a problem.