Search code examples
rdataframematrixnaming

Assigning numerical rownames() to data.frame in decimal increments in R


I have a data.frame that contains the data from 180 iterations of a script I ran previously. To be thorough (and to make reading the data easier), I was wondering if there's a way to name rows in a way that reflects these iterations wherein I tested my conditions at various thresholds.

At each iteration, my threshold increases by 0.1. Rather than naming my rows using,

rownames(data) <- c(1:180) 

I'd like to name them from 1 - 18, also increasing by 0.1. So, 1, 1.1, 1.2, ..., 17.9, 18.0.

Can this be done? Thank you!


Solution

  • You can use the seq function:

     rownames(data) <- seq(from = 1, to = 18, by = 0.1)
    

    Note that this will give you 181 numbers, so you might want to start at 1.1