How can I change the range of the number in a column in R?

I have numbers in a column whose range from -5 to 7. I want to range them from 0 to 13. How can I do that in R?

Thank you in advance.

>Solution :

as in a new column of data, or add 5 to current column?

Both below

df$col <- df$col+5

df$new <- sample(0:13, 10)

hope this helps

Leave a Reply