[R] replace text by uniqe number

Jim Lemon drjimlemon at gmail.com
Thu Mar 10 03:38:39 CET 2016

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:



On Wed, Mar 9, 2016 at 7:10 PM, Ragia . <ragia11 at 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 at 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.

More information about the R-help mailing list