I have an existing data.table that I am wanting to add an 'identity' column to.
I know how to add a column e.g:
DT$newCol <- x
However I am struggling to make the new value an auto-incrementing counter from 1 to n.
I would have asked as a comment to this question (data.table "key indices" or "group counter") as it is related, however I don't have enough reputation to comment.
Thanks in advance.