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?
✗ Incorrect
The c() function is the standard way to create vectors in R.
What happens if you combine numbers and text in one vector in R?
✗ Incorrect
R converts all elements to character type to keep the vector consistent.
How do you check the type of a vector in R?
✗ Incorrect
typeof() returns the internal type of the vector elements.
Which of these is a numeric vector in R?
✗ Incorrect
c(1, 2, 3.5) contains only numbers, so it is a numeric vector.
What type of vector is created by c("apple", "banana")?
✗ Incorrect
The vector contains text strings, so it is a character vector.
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.