To create a set of numbers from 1 to N in R, you can use the colon operator (:) to generate a sequence of numbers and convert it to a set.
In this example,
seq
function to generate a sequence of numbers from 1 to 5 using the colon operator 1:5
.as.set
function to create the set.mySet <- as.set(1:5)
print(mySet)
[1] 1 2 3 4 5
In this example,
seq
function to generate a sequence of numbers from 1 to 10 using the colon operator 1:10
.as.set
function to create the set.mySet <- as.set(1:10)
print(mySet)
[1] 1 2 3 4 5 6 7 8 9 10
In this tutorial, we learned How to create a Set of Numbers from 1 to N in R language with well detailed examples.