Вот возможность:
library(tidyverse)
df1<-read.table(text="Patient Cell Count
BB-01-D1 7
BB-02-D1 4
BB-04-D30 2",header=T,fill=T)
df1<-df1[,-ncol(df1)]
df2<-read.table(text="Patient, Cell Count
2-5-19_BB-01-D1 7
3-15-19_BB-04-D30 2
2-6-19_BB-02-D1 4",header=T,fill=T)
df2<-df2[,-ncol(df2)]
df2<-df2 %>%
mutate(Patient.=str_remove_all(df2$Patient.,".*(?<=_)"))
Тогда продолжайте, как пожелаете
cbind(df1,df2) #Cell Count labels lost due to reading errors. Will work on
#my data import
Patient Cell Patient. Cell
1 BB-01-D1 7 BB-01-D1 7
2 BB-02-D1 4 BB-04-D30 2
3 BB-04-D30 2 BB-02-D1 4
OR
df1<-df1 %>%
mutate(Patient=as.factor(Patient))
df2<-df2 %>%
rename(Patient=Patient.) %>%
mutate(Patient=as.factor(Patient))
merged<-df1 %>%
left_join(df2,"Patient")
names(merged)<-c("Patient","Clinical","Flow")
Результат:
Patient Clinical Flow
1 BB-01-D1 7 7
2 BB-02-D1 4 4
3 BB-04-D30 2 2