make vector going from 0 to 300 in increments of 10 in r

In R, you can use the seq() function to create a vector going from 0 to 300 in increments of 10. The seq() function takes three arguments: the starting point, the end point, and the increment.

Here's how you can use seq() to create the desired vector:

my_vector <- seq(0, 300, 10)
29 chars
2 lines

This will create a vector named my_vector that starts from 0, ends at 300, and increments by 10. You can adjust the values passed to seq() to customize the range and increment as per your requirements.

You can also achieve the same result using the colon operator ::

my_vector <- 0:300
19 chars
2 lines

This creates a sequence from 0 to 300 with an implicit increment of 1. To change the increment to 10, you can use the seq() function as shown earlier.

related categories

gistlibby LogSnag