I would like to number the elements of a vector, assigning \'1\' to the smallest element in the vector. I know how to do this, but my solution (code included below) seems o
If you're using numeric or integer data you can use as.numeric(factor())
as.numeric(factor())
dat <- c(5,8,12,12,8,3,100) as.numeric(factor(dat))
Also, as a side note, you should avoid using data as a variable name in R since its already a built-in function.
data
R