Add a new column with tag attached to crescent num

2020-03-30 16:09发布

I would like to add a new collumn giving a constant tag with anexed with a crescent numbers logic, line after line.

My input:

position  work  

chr1    jil2001
chr4    jil2001
chr3    kou2009
chr9    nai2012
chr7    fandis2005

My expected output:

position  work    tag

chr1    jil2001  Known1
chr4    jil2001  Known2
chr3    kou2009  Known3
chr9    nai2012  Known4
chr7    fan2005  Known5

Cheers!

标签: r tags numbers
1条回答
你好瞎i
2楼-- · 2020-03-30 17:02

You can create the new column manually;

df$tag <- paste0("Known", seq_len(nrow(df)))
查看更多
登录 后发表回答