- I have opened a file in RStudio and text is messed up (no diacritics, etc.)!
You need to click on File -> Reopen with Encoding and set the encoding to UTF-8. The same encoding is preferable if you create your own file. UTF-8 is an international character encoding standard that is compatible with a wide variety of scripts and languages (Slavic, Arabic, Spanish, etc.), and I recommend using it everywhere.
- I have read CSV file in R, and text in my data frame is messed up!
If you have a problem reading a file (for example, using the read.csv function), you simply need to add the encoding argument to the function call (read.csv(..., encoding = "UTF-8")).
- When I am executing code from my file (one block after another), it works perfectly, but during knitting, there are errors! Why does knitting not work?
You need to check a couple of things
a) Is there any install.packages function call? If yes, remove it.
b) Are files (for example read by read.csv function) in the right directory? Remember: during knitting a working directory is set to the directory where knitted file is located and not to the directory you set in the interactive session using setwd.
c) Are all variables defined in your code? Maybe you defined something outside the file (in console) and forgot to put the code in the file?
Besides that, read error messages, they do not bite.
- I have run some R code and it seems that R hanged and does not want to run any code anymore!
You probably made a syntax error, and the R interpreter does not know how to execute your code. Typically you can diagnose it by looking at the interpreter prompt - it should start with >. If it starts with +, it means that R waits until expression is completed (trust me if you messed up it won’t be completed). The most common mistake is a missing quote.
The best way to resolve this problem is to hit Escape on the keyboard and try again. Doing this should restore “proper” prompt (>) and you will be able to run code. Remember that executing the same code a second time will probably not help.