0

I have a question to create unique consumer_id using R.

Here is the expected data set.The original data has name and order_no.

name order_no. consumer_id
a     #1000     1
      #1000     1
      #1000     1
b     #1001     2
c     #1002     3
      #1002     3
d     #1003     4
David Arenburg
  • 91,361
  • 17
  • 137
  • 196
user3849475
  • 267
  • 3
  • 4
  • 12
  • 1
    Are you looking for something like `dat$consumer_id <- as.numeric(as.factor(dat$order_no))`? It's tough to tell exactly what sort of data you have without the output of something like `dput(dat)` for your data frame `dat`. – josliber Mar 16 '16 at 20:53
  • @josliber the original data has name and order_no.,but I want to create new id with unique consumer_id,like 3rd column. – user3849475 Mar 16 '16 at 21:03
  • OK, I'm pretty sure the duplicate I marked (and the code in my comment) do what you're asking; if not please edit your question to give more details about how the consumer_id is generated from the data. – josliber Mar 16 '16 at 21:06

0 Answers0