提问人:Mohamed Rahouma 提问时间:4/27/2022 最后编辑:Mohamed Rahouma 更新时间:6/25/2022 访问量:60
将使用 R 中的 TriMatch 包获得的数据重塑为另一个数据,保留匹配的三元组序列 ID 以供进一步分析
Reshape data obtained using TriMatch package in R to another data keeping matched triplets serial ID for further analysis
问:
如何将数据 A(使用 package in 获得)重塑为数据 B,并保持匹配的三元组序列 ID 以允许进一步分析?TriMatch
R
用于获取数据 A 及其结构的代码:
formu <- ~ Age+FEMALE+renal_insuf+Diabetes+MI+LVEF_pre+ Crea+ NYHA+treated_Hypertension + PVD+CVA +PTCA+ offpump+ngrafts+TRIAL
#======================================================================================================================
library(TriMatch)
tpsa <- trips(data, data$conduit, formu) #tpsa the results from trips=Estimates propensity scores for three groups
data1.matched <- trimatch(tpsa)
matched.out <- merge(data1.matched, data)
str( matched.out)
###################
data.frame': 1776 obs. of 67 variables:
$ BITA : chr "3947" "7787" "8334" "3954" ...
$ LITA+RA : chr "9405" "4711" "7486" "6660" ...
$ LITA+SVG : chr "4440" "9216" "8683" "5432" ...
$ D.m3 : num 0.000877 0.000227 0.001541 0.000446 0.000854 ...
$ D.m2 : num 0.000481 0.001296 0 0.000515 0.001079 ...
$ D.m1 : num 9.84e-05 1.49e-04 1.67e-04 9.69e-04 2.29e-04 ...
$ Dtotal : num 0.00146 0.00167 0.00171 0.00193 0.00216 ...
$ BITA.Serial.ID : num 4709 9000 9596 4716 2401 ...
$ BITA.conduit : Factor w/ 3 levels "LITA+SVG","BITA",..: 2 2 2 2 2 2 2 2 2 2 ...
$ BITA.Age : num 66 42 65 65 71.6 ...
$ BITA.FEMALE : num 1 0 1 0 0 0 0 0 0 0 ...
$ BITA.renal_insuf : num 0 0 0 0 0 0 0 0 0 0 ...
$ BITA.Diabetes : num 1 0 0 1 0 0 1 0 0 0 ...
$ BITA.MI : num 1 1 1 1 0 0 0 0 0 0 ...
$ BITA.LVEF_pre : num 1 1 1 1 0 1 1 1 1 1 ...
$ BITA.BMI : num 26.6 43.9 37.1 30.5 24.9 ...
$ BITA.Crea : num 53.1 79.6 79.6 123.8 103 ...
$ BITA.NYHA : num 0 1 0 0 0 1 1 0 0 0 ...
$ BITA.treated_Hypertension : num 1 1 1 1 1 0 1 0 1 1 ...
$ BITA.treated_Hyperlipaemia : num 0 0 1 1 1 0 0 1 1 1 ...
$ BITA.PVD : num 0 0 0 1 0 0 0 0 0 0 ...
$ BITA.CVA : num 0 0 0 0 0 0 0 1 0 0 ...
$ BITA.PTCA : num 0 1 0 1 0 0 0 0 0 0 ...
$ BITA.AF_pre : num 0 0 0 0 0 0 0 0 0 0 ...
$ BITA.offpump : num 1 0 1 0 1 0 0 1 1 1 ...
$ BITA.ngrafts : num 4 4 5 4 3 4 3 3 4 2 ...
$ BITA.TRIAL : num 2 4 4 2 1 4 2 2 2 2 ...
$ LITA+RA.Serial.ID : num 10772 5535 8678 7754 1734 ...
$ LITA+RA.conduit : Factor w/ 3 levels "LITA+SVG","BITA",..: 3 3 3 3 3 3 3 3 3 3 ...
$ LITA+RA.Age : num 60 60 61 79 74.1 ...
$ LITA+RA.FEMALE : num 0 0 0 0 0 1 1 1 1 0 ...
$ LITA+RA.renal_insuf : num 0 0 0 0 0 0 0 0 0 0 ...
$ LITA+RA.Diabetes : num 0 1 0 1 0 0 1 0 0 1 ...
$ LITA+RA.MI : num 1 1 1 1 0 0 0 0 0 0 ...
$ LITA+RA.LVEF_pre : num 0 1 1 1 0 1 1 1 1 1 ...
$ LITA+RA.BMI : num 26.1 25 28.5 36.5 27.4 ...
$ LITA+RA.Crea : num 79.6 79.6 79.6 98 82 ...
$ LITA+RA.NYHA : num 0 0 0 1 0 0 1 0 0 1 ...
$ LITA+RA.treated_Hypertension : num 0 1 1 1 0 1 0 1 1 1 ...
$ LITA+RA.treated_Hyperlipaemia : num 1 1 1 1 1 1 1 0 1 1 ...
$ LITA+RA.PVD : num 0 0 0 0 0 1 0 0 0 1 ...
$ LITA+RA.CVA : num 0 0 0 0 0 1 0 0 0 0 ...
$ LITA+RA.PTCA : num 0 0 0 0 1 0 0 0 0 0 ...
$ LITA+RA.AF_pre : num 0 0 1 0 0 0 0 0 0 0 ...
$ LITA+RA.offpump : num 1 1 0 1 1 0 1 1 1 1 ...
$ LITA+RA.ngrafts : num 3 3 4 3 2 4 2 4 3 2 ...
$ LITA+RA.TRIAL : num 4 2 4 2 1 4 2 2 2 2 ...
$ LITA+SVG.Serial.ID : num 5250 10571 9971 6360 2846 ...
$ LITA+SVG.conduit : Factor w/ 3 levels "LITA+SVG","BITA",..: 1 1 1 1 1 1 1 1 1 1 ...
$ LITA+SVG.Age : num 73 51 61 63 54.1 ...
$ LITA+SVG.FEMALE : num 0 0 0 0 1 0 1 0 0 1 ...
$ LITA+SVG.renal_insuf : num 0 0 0 0 0 0 0 0 0 0 ...
$ LITA+SVG.Diabetes : num 0 1 0 1 0 0 0 1 1 1 ...
$ LITA+SVG.MI : num 1 0 1 0 0 1 0 0 1 0 ...
$ LITA+SVG.LVEF_pre : num 1 0 1 1 0 1 1 1 1 1 ...
$ LITA+SVG.BMI : num 20.2 27 27.1 29.4 26.6 ...
$ LITA+SVG.Crea : num 97.3 106.1 79.6 106.1 97.2 ...
$ LITA+SVG.NYHA : num 0 0 0 1 0 1 0 0 1 1 ...
$ LITA+SVG.treated_Hypertension : num 0 1 1 1 0 1 1 1 1 1 ...
$ LITA+SVG.treated_Hyperlipaemia: num 1 1 1 1 1 0 1 1 1 1 ...
$ LITA+SVG.PVD : num 0 0 0 1 0 0 0 1 0 0 ...
$ LITA+SVG.CVA : num 0 0 0 0 0 0 0 0 0 0 ...
$ LITA+SVG.PTCA : num 0 0 0 0 0 0 0 0 0 0 ...
$ LITA+SVG.AF_pre : num 0 0 0 1 0 0 0 0 0 0 ...
$ LITA+SVG.offpump : num 0 0 0 1 0 0 0 0 0 1 ...
$ LITA+SVG.ngrafts : num 2 5 4 2 2 3 3 3 2 3 ...
$ LITA+SVG.TRIAL : num 2 4 4 2 1 4 2 2 2 2 ...
数据B结构:
Classes ‘data.table’ and 'data.frame': 5328 obs. of 32 variables:
$ Serial.ID : int 4709 9000 9596 4716 2401 8978 7460 4974 4704 3929 ...
$ conduit : chr "BITA" "BITA" "BITA" "BITA" ...
$ Age : num 66 42 65 65 71.6 ...
$ FEMALE : int 1 0 1 0 0 0 0 0 0 0 ...
$ renal_insuf : int 0 0 0 0 0 0 0 0 0 0 ...
$ Diabetes : int 1 0 0 1 0 0 1 0 0 0 ...
$ MI : int 1 1 1 1 0 0 0 0 0 0 ...
$ LVEF_pre : int 1 1 1 1 0 1 1 1 1 1 ...
$ BMI : num 26.6 43.9 37.1 30.5 24.9 ...
$ Crea : num 53.1 79.6 79.6 123.8 103 ...
$ NYHA : int 0 1 0 0 0 1 1 0 0 0 ...
$ treated_Hypertension : int 1 1 1 1 1 0 1 0 1 1 ...
$ treated_Hyperlipaemia: int 0 0 1 1 1 0 0 1 1 1 ...
$ PVD : int 0 0 0 1 0 0 0 0 0 0 ...
$ CVA : int 0 0 0 0 0 0 0 1 0 0 ...
$ PTCA : int 0 1 0 1 0 0 0 0 0 0 ...
$ AF_pre : int 0 0 0 0 0 0 0 0 0 0 ...
$ offpump : int 1 0 1 0 1 0 0 1 1 1 ...
$ ngrafts : int 4 4 5 4 3 4 3 3 4 2 ...
$ TRIAL : chr "CORONARY" "PREVENT-IV" "PREVENT-IV" "CORONARY" ...
任何建议将不胜感激。
答: 暂无答案
评论