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 . <ragi...@hotmail.com> wrote:
> Dear group
> kindly if i had data frame of 2 columns that has repeated URLS ..and want to 
> replace those urls with ID's for each one so the url will have
> unique ID, how  can I do this
> thanks in advance
> e.g otf  data
>
> pcworld.com     open.itworld.com
> pcworld.com     storage.itworld.com
> salon.com       images.salon.com
> go.theregister.com      theregister.co.uk
> techchuck.com   pcworld.com
> ecoustics.com   pcworld.com
>
> Ragia
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to