Basic syntax in R
- Slides for this lesson
- Demo script for this lesson
Quotes indicate text
Every value that is written in between quotes and that does not have a date format is interpreted as character (text) in R.
Single or double quotes?
Both are ok to indicate text or dates: single and double quotes have the same meaning in R.
Copying quotes from pdf gives issues!
When you copy text with quotes from a pdf file and you paste the text in R, the quotes will look good but R will not understand them. R will have issues with these quotes. You will have to retype the quotes in R. The file with the exercises is a pdf file!
Quotes that are part of text
You have to escape quotes that are part of text by putting a \ in front of them. When you do something with the text, R will understand that the quotes are part of the text and will not interpret them as quotes that indicate the start or the end of a character string.
text <- "she said \"Hello\""
More info on using and escaping quotes can be found in the documentation by running the following code in the console:
?Quote