[R] how to convert a set of strings to a list of unique numeric id?

From: G FANG <fanggangsw_at_gmail.com>
Date: Sun, 20 Jun 2010 16:46:38 -0700


Hi,

I have been a matlab user and is learning R.

I want to convert a large list of strings to a list of unique numeric ids to reduce storage space.

For example,

there is a string list (there are duplicates)

ABCDDDD
ACCDEDF
ACCGEDF
ACCGEGF
.....

ACCDEDF
ACCGEGF and I want to have a corresponding numeric id list

1
2
3
4
....

2
4

In matlab, the 'unique' function can do this in addition to give the unique set, but in R, 'unique' only gives the unique set

Please advice me on this.

Thanks,

Gang



R-help_at_r-project.org mailing list
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. Received on Sun 20 Jun 2010 - 23:49:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 21 Jun 2010 - 00:20:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive