Complete the code to create a numeric vector with values 1, 2, and 3.
vec <- c([1])c(1:3) inside c() is redundant.The c() function combines values into a vector. Here, 1, 2, 3 creates a numeric vector.
Complete the code to create a character vector with the names "apple", "banana", and "cherry".
fruits <- c([1])Character values must be in quotes inside the c() function. Double quotes are standard in R.
Fix the error in the code to create a numeric vector from 5 to 10.
numbers <- [1](5, 10)
c(5, 10) creates a vector with only two numbers, not a sequence.vector() creates an empty vector, not a sequence.The seq() function generates sequences from a start to an end number. c(5, 10) just combines two numbers.
Fill both blanks to create a character vector of three fruits and check its type.
fruits <- c([1]) is_char <- is.[2](fruits)
The vector must contain character strings in quotes. The function is.character() checks if the vector is character type.
Fill all three blanks to create a numeric vector, get its length, and access the second element.
nums <- c([1]) len <- length([2]) second <- [3][2]
c(10, 20, 30) inside c() causes nested vectors.Use c(10, 20, 30) to create the vector, but since the blank is inside c(), only the numbers go in the first blank. The variable nums is used to get length and access elements.