I have two tables that I would like to combine to create a summary table
df1 <- data.frame(median=c(151, 98, 125, 47),
Q25=c(148, 90, 120, 44),
Q75=c(158, 104, 132, 53),
pass_or_fail=c('pass')
)
row.names(df1)<-c("param1", "param2", "param3", "param4")
df1
df2 <- data.frame(median=c(148, 95, 135, 40),
Q25=c(140, 88, 130, 35),
Q75=c(150, 100, 141, 45),
pass_or_fail=c('fail')
)
row.names(df2)<-c("param1", "param2", "param3", "param4")
df2
rbind(df1, df2)
The output I am looking for is shown below, where the rownames shared between the 2 dataframes, columns are grouped by “pass” or “fail”, and the value is shown as the median with IQR in brackets
The result of the rbind is altered row names as duplicate names are not allowed. I am wondering how I can overcome the issue of the rownames being renamed, and if the IQR can be shown in brackets using kable or another function.
Thank you!