问题
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