I've got two data tables as below:
> have1
Column1 Column2 Column3
1: 100 200 159
2: 169 506 101
3: 100 200 636
---
123571 456 559 249
123572 654 883 423
> have2
variable value
1: Apple 0.25
2: Orange 2.68
3: Pear 0.11
---
10: Grape 5.27
What I'm trying to do is to add the variable from 'have2' as columns and value as constant to 'have1', so the 'want' is:
> want
Column1 Column2 Column3 Apple Orange Pear.... Grape
1: 100 200 159 0.25 2.68 0.11 5.27
2: 169 506 101 0.25 2.68 0.11 5.27
3: 100 200 636 0.25 2.68 0.11 5.27
---
123571 456 559 249 0.25 2.68 0.11 5.27
123572 654 883 423 0.25 2.68 0.11 5.27
I'm hoping to not use dplyr and stick with base R or data.table.
This merging will need to be applicable for different sets of 'have1' & 'have2' and 'want', so trying to avoid manually listing all the variables in the cbind (i.e., cbind(have1, Apple=0.25 etc...)...)
Any help, suggestions would be appreciated, thank you!!