I wish to append a numeric onto a character vector, so that each row receives a unique numeric different to the previous, though +1 relative to the previous. Such that n+1.
I have tried:
test.all$ly_name <- sub("^", 1:nrow(test.all$ly_name), test.all$ly_name )
What it looks like:
1Prairie_Potholes
1Prairie_Potholes
1Prairie_Potholes
.
.
.
expected:
Prairie_Potholes1
Prairie_Potholes2
Prairie_Potholes3
.
.
.
However, this only assign the first numeric, 1.
reproducible code:
c("Prairie_Potholes", "Prairie_Potholes", "Prairie_Potholes",
"Prairie_Potholes", "Prairie_Potholes", "Prairie_Potholes", "Prairie_Potholes",
"Prairie_Potholes", "Prairie_Potholes", "Boreal_Hardwood_Transition",
"Boreal_Hardwood_Transition", "Boreal_Hardwood_Transition", "Boreal_Hardwood_Transition",
"Boreal_Hardwood_Transition", "Boreal_Hardwood_Transition")