简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM