Skip to content
Prev 359182 / 398502 Next

replace text by uniqe number

Hi Ragia,
If you have read in your data frame with read.table or similar and not
specified stringsAsFactors=FALSE, the two columns will already be
factors. However, unless they both contain the same number of unique
values, the numbers associated with those levels won't be the same.
Probably the easiest way to get the same IDs for both is to read in
the data with stringsAsFactors=FALSE and then convert the two columns:

url_levels<-unique(unlist(otf_data))
otf_data[,1]<-factor(otf_data[,1],levels=url_levels)
otf_data[,2]<-factor(otf_data[,2],levels=url_levels)

Jim
On Wed, Mar 9, 2016 at 7:10 PM, Ragia . <ragia11 at hotmail.com> wrote: