Sequences
The :
operator helps us create sequences of numbers.
For example, 32:99
would create a list of numbers from 32 to 99.
Then, if we want to know the length of this sequence, all we need to do is use the length
command.
This exercise is part of the course
Data Science R Basics
Exercise instructions
This time we will use just the :
operator.
Use the :
operator to create a sequence of consecutive integers starting at 12 and ending at 73 and save it in an object x
, then determine the length of object x
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create a vector m of integers that starts at 32 and ends at 99.
m <- 32:99
# Determine the length of object m.
length(m)
# Create a vector x of integers that starts at 12 and ends at 73.
# Determine the length of object x.