R numbers from 1 to 100

r

Solution

Your mistake is looking for `range`, which gives you the `range` of a vector, for example:

range(c(10, -5, 100))

gives

 -5 100

Instead, look at the `:` operator to give sequences (with a step size of one):

1:100

or you can use the `seq` function to have a bit more control. For example,

##Step size of 2
seq(1, 100, by=2)

or

##length.out: desired length of the sequence
seq(1, 100, length.out=5)

Problem

Possible Duplicate: How to generate a vector containing a numeric sequence? In R, how can I get the list of numbers from 1 to 100? Other languages have a function 'range' to do this. R's range does something else entirely. ``` > range(1,100) [1] 1 100 ```

Original source

Related problems