...

/

All About Strings

All About Strings

This chapter introduces you to the basic concepts of character strings in R.

Creating Character Strings

In R, we can express character strings by surrounding text with double quotes:

“learning is fun”,

or we can also surround text with single quotes:

‘learning is fun’.

cat("learning is fun")
Creating string using double quotes

Empty String

The most basic type of string is the empty string produced by consecutive quotation marks: "".

"" is a string with no characters in it, hence the name empty string:

cat("")
Empty string using double quotes

Escape Sequences

A sequence that starts with a \ in a string is called an escape sequence. It allows us ...