0
0
R Programmingprogramming~5 mins

Numeric and character vectors in R Programming - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a numeric vector in R?
A numeric vector in R is a sequence of numbers stored in a single variable. It can hold integers or decimal numbers.
Click to reveal answer
beginner
How do you create a character vector in R?
You create a character vector by combining text strings using the c() function, for example: c("apple", "banana", "cherry").
Click to reveal answer
beginner
What function is used to combine elements into a vector in R?
The c() function is used to combine elements into a vector, whether numeric or character.
Click to reveal answer
intermediate
Can a vector in R contain both numbers and text at the same time?
No, a vector in R must contain elements of the same type. If you mix numbers and text, R converts all elements to character type.
Click to reveal answer
beginner
How do you check the type of a vector in R?
You use the typeof() function to check the type of a vector, for example: typeof(my_vector).
Click to reveal answer
Which function creates a vector in R?
Ac()
Bvectorize()
Ccombine()
Dmake_vector()
What happens if you combine numbers and text in one vector in R?
AR throws an error
BThe vector becomes numeric
CThe vector becomes logical
DThe vector becomes character
How do you check the type of a vector in R?
Aclass()
Bmode()
Ctypeof()
Dtype()
Which of these is a numeric vector in R?
Ac(1, 2, 3.5)
Bc(1, "a", 3)
Cc(TRUE, FALSE)
Dc("a", "b", "c")
What type of vector is created by c("apple", "banana")?
Alogical
Bcharacter
Cnumeric
Dinteger
Explain how to create and identify numeric and character vectors in R.
Think about how you combine elements and check their type.
You got /4 concepts.
    What happens when you mix numbers and text in one vector in R? Why?
    Consider how R keeps vectors consistent.
    You got /3 concepts.