Add a new column with tag attached to crescent numbers

我的未来我决定 提交于 2019-12-01 10:05:14

问题


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!


回答1:


You can create the new column manually;

df$tag <- paste0("Known", seq_len(nrow(df)))


来源:https://stackoverflow.com/questions/22883998/add-a-new-column-with-tag-attached-to-crescent-numbers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!