I was trying to produce a PDF file with the knitr in RStudio but I encountered a problem. I have read a lot of solutions found on stack overflow and google but they are not very
I have figured out what the problem is, that you have to choose WINDOWS-1252 as your text encoding.
If you have set other types as default, change it at tools> global options > code > saving, choose [Ask] in the default text encoding.
Hope that works for you.
I do not think that it is workable way by switching something or set something. Just carefully check your code, particularly the part you copy from somewhere, not type it by your self.
I have the same problem recently.
I show you How I solve this problem.
I remove the code from the R markdown part by part to find which part caused this problem. Finally, I found the below part that resulted in the error in my code.
### Platform:Affymetrix A-AFFY-2-Affymetrix GeneChip Arabidopsis Genome [ATH1-121501].
I remember I copy this information from webpage. So I delete them and type this part by myself. It can run and generate the pdf file without any error.
To be clear, I show you the difference between the copy version and the version of my typing:
This is just one example I think. I want to point out that it is always problematic when you copy something from an unknown resource file into your code.
Hope this can help you and other people who were frustrated by this problem.