0
0
R Programmingprogramming~5 mins

Character (string) type in R Programming - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a character type in R?
A character type in R is used to store text or strings, like words or sentences, inside quotes.
Click to reveal answer
beginner
How do you create a character string in R?
You create a character string by putting text inside single or double quotes, for example: "hello" or 'world'.
Click to reveal answer
beginner
What function checks if a value is a character in R?
The function is.character() returns TRUE if the value is a character string, otherwise FALSE.
Click to reveal answer
beginner
How does R treat a single letter inside quotes?
R treats a single letter inside quotes as a character string of length one, not as a separate type.
Click to reveal answer
intermediate
What happens if you mix numbers and characters in a vector in R?
R converts all elements to character type because a vector must have elements of the same type.
Click to reveal answer
How do you create a character string in R?
APut text inside quotes, like "hello"
BWrite text without quotes
CUse the number format
DUse the TRUE or FALSE keywords
What does is.character("R") return?
AAn error
BFALSE
CTRUE
DNULL
What type does R assign to c("a", 1, TRUE)?
ALogical
BNumeric
CList
DCharacter
Which function checks if a variable is a character string?
Ais.character()
Bis.numeric()
Cis.logical()
Dis.vector()
What is the length of the character string "a" in R?
A0
B1
C2
DDepends on the font
Explain how R handles character strings and how to create them.
Think about how you write words in R code.
You got /3 concepts.
    Describe what happens when you mix characters and numbers in a vector in R.
    Remember vectors need one type only.
    You got /3 concepts.