0
0
R Programmingprogramming~5 mins

Vector creation with c() in R Programming - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the c() function do in R?
The c() function combines values into a vector, which is a basic data structure in R that holds elements of the same type.
Click to reveal answer
beginner
How do you create a numeric vector with the numbers 1, 2, and 3 using c()?
You write c(1, 2, 3). This creates a vector containing the numbers 1, 2, and 3.
Click to reveal answer
intermediate
Can c() combine different types like numbers and characters in one vector?
Yes, but R will convert all elements to the most flexible type to keep the vector consistent. For example, combining numbers and characters will convert numbers to characters.
Click to reveal answer
beginner
What happens if you use c() with no arguments?
It creates an empty vector with no elements.
Click to reveal answer
intermediate
How does c() differ from other vector creation functions like seq() or rep()?
c() combines specific values you list, while seq() creates sequences of numbers and rep() repeats values. c() is for manual combination.
Click to reveal answer
What does c(4, 5, 6) create in R?
AA vector with elements 4, 5, and 6
BA list with elements 4, 5, and 6
CA matrix with elements 4, 5, and 6
DAn error because of missing quotes
What type will the vector c(1, "a", TRUE) have?
AMixed types allowed
BNumeric
CLogical
DCharacter
What is the result of c() with no arguments?
AAn empty vector
BAn error
CA vector with one NA
DNULL
Which function is best to create a vector repeating the number 3 five times?
Ac(3, 3, 3, 3, 3)
Brep(3, 5)
Cseq(3, 5)
Dc(3:5)
If you want to combine the numbers 1, 2, and 3 into a vector, which is correct?
Acombine(1, 2, 3)
Bvector(1, 2, 3)
Cc(1, 2, 3)
Dseq(1, 3)
Explain how the c() function works to create vectors in R.
Think about how you put things together in a row.
You got /4 concepts.
    Describe what happens when you mix numbers and characters inside c().
    Consider how R keeps things consistent.
    You got /3 concepts.