0

I have a dataset like this:

retailer_id transaction_id  user_id products    total      
D31 700 4   water   1      
D31 701 17  coffee  2      
D31 702 68  coffee  2      
D31 703 78  water   1      
D31 704 4   juice   3    

where the retailer_id column will only ever have one value. I will create multiple vectors, e.g. total cost, average price and whatever else and then I want to join them into a dataframe or vector that takes the name D31. I cannot find any process which would pull D31 and then make a new vector or dataframe with that name.

Since I am automating this as part of a reporting process, I need to have the name of this new dataframe that the value within retailer_id.

989
  • 12,579
  • 5
  • 31
  • 53
  • 1
    Please provide some form of [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Why do you think you need to dynamically create variable names? Can't you store the data in a named list or something? It doesn't sound like you are doing things in a very R-like way. – MrFlick Jul 29 '15 at 16:58
  • 4
    Your question seems pretty unclear to me, but I suppose you're looking for `assign`. Or at list you think you are looking for it. Probably better than using "variable variable names" is using a list. – CL. Jul 29 '15 at 16:58
  • Please look through this [post on making great R examples](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Your question currently does not contain a [MVCE](http://stackoverflow.com/help/mcve). – Richard Erickson Jul 29 '15 at 16:58
  • Sorry was struggling to get the image in. My apologies. I will be building it as part of an overall reporting process, so it needs to automatically take this name. – Anna Dudek Jul 29 '15 at 17:02
  • You need to explain why this was not completely answered by user2706569's comment. – IRTFM Jul 29 '15 at 19:44
  • I think I don´t understand very well your question but I believe `str_split_fixed()` could help you to do what you want. You could use `" "` for splitting your variable `retailer_id`. – Edu Jun 29 '16 at 14:26

0 Answers0