If you want to assign numbers to lines, rather than deleting the text "line", you can use a coefficient with known levels, and then force a number.
d <- read.csv(header=TRUE, file=textConnection("a,b,c string1,string2,value1 string3,string1,value2 string3,string5,value3")) l=unique(c(as.character(d$a), as.character(d$b))) d1 <- data.frame(a=as.numeric(factor(d$a, levels=l)), b=as.numeric(factor(d$b, levels=l)), c=d$c) > d1 abc 1 1 3 value1 2 2 1 value2 3 2 4 value3
Please note that the selected numerical values do not match the numbers in the lines, but each line is assigned a unique number.
source share