I want to merge two dataframes in R by column vector name.
The first dataframe would have and ID
variable as this:
H01
H02
H03
H05
And the second dataframe would have an ID
variable like this:
H01_1
H02_1
H03_1
H04_1
I want to merge the dataframes, keeping only the columns that are present in both dataframes. So in the previous example H04_1
wouldn´t be in the merged dataframe as it wasn´t present in the first one.
I was thinking of changing the names of the variable:
exclusion %>%
mutate(Subject = str_sub(Subject, 1, 3))
and then merging, but is there any other simpler way?