I have a question concerning R and changing values of a numeric sequence. I do have a column in a data.table which looks something like X here:
X <- data.table(id = c("103", "103", "103", "104", "104", "160", "160"),
content = c("I", "don't", "know", "some", "more", "words", "."))
And I would like to replace the id values with sequential values to change the starting point and to get rid of the gaps in between. In the real life problem, there would be thousands of id values, so grep-ing them wouldn't be a possibility.
So what I would like to achieve is something like this:
Y <- data.table(id = c("0", "0", "0", "1", "1", "2", "2"),
content = c("I", "don't", "know", "some", "more", "words", "."))
Any hint would be welcome as I don't know how to start. Thank you so much in advance!