Vlookup/Merge/Join Several CSV with No Headers in R

I have several csv files with no headers and the only commonality is the first column that always has the users unique ID. I want to create one csv file that combines specific information based on the user ID chosen.

So for example there is:

table 1 (which has no header but for guidance the columns are ID, Name, Birthday)

80938        	     James	              Nov-00
78397	              Tom	              Jul-20
73820	              Pam	              Sep-10

and table 2 (which has no header but for guidance the columns are ID, Product Category, Purchase in 2012, Purchase in 2013, Purchase in 2014, Purchase in 2015)

80938	      1	          500000	        600000	            700000	           800000
80938	      2	            333	             456	               567	             467
80938	      3	            444	             456	               399	             799

I want to create the combined table below

ID: 80938
Name: James
Birthday: Nov-00
Product: 1
	                2012	           2013	           2014	           2015
Purchase	      500000           	  600000	      700000	      800000

Welcome to the community!

I think merge does what you want. It's not in the same format as you shown, but it'llbe able to join the two tables in a single data.frame, which you can later convert to a CSV using write.csv.

table_1 <- read.table(text = "80938              James                Nov-00
78397                 Tom                 Jul-20
73820                 Pam                 Sep-10",
                      col.names = c("ID", "Names", "Birthday"))

table_2 <- read.table(text = "80938       1           500000            600000              700000             800000
80938         2             333              456                   567               467
80938         3             444              456                   399               799",
                      col.names = c("ID", "ProduceCategory", "Purchase2012", "Purchase2013", "Purchase2014", "Purchase2015"))

merge(x = table_1,
      y = table_2,
      by = "ID")
#>      ID Names Birthday ProduceCategory Purchase2012 Purchase2013 Purchase2014
#> 1 80938 James   Nov-00               1       500000       600000       700000
#> 2 80938 James   Nov-00               2          333          456          567
#> 3 80938 James   Nov-00               3          444          456          399
#>   Purchase2015
#> 1       800000
#> 2          467
#> 3          799

If you want other type of joins, you can use different values for all, all.x and all.y, and those are present in ?merge.

There is a very popular SO thread. There you'll get solutions using non-standard libraries as well.

Hope this helps.