Question: In this exercise, you will practice vector subsetting. First run the following lines of code to create a vector x : x - seq (
In this exercise, you will practice vector subsetting.
First run the following lines of code to create a vector :
seq # search help to find out what seq does.
names letters : # "letters" is an alphabet vector defined by R
a b c d e
Note that is a vector of values from to and cach element is named by a letter in the alphabet.
gives you the flexibility to subset a vector in multiple ways. Use each of the following ways to subset to generate a vector of values :
a Subset by elements indices using the function.
b Subset using the colon operator for vector slicing.
Subset with a logical index vector.
d Subset using the names of the corresponding elements.
e Remember negative index can be used to delete an element from the vector? Use an index vector of negative values to subset
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
