我试着做一个这样的平衡表,用R表示:
我希望能够将其输出到HTML并重新标记列,并有一个选项来显示两组之间的平均值比较的p值。crosstable
包几乎可以工作,但我找不到一种方法来将分类变量视为连续变量。代码如下:
library(crosstable)
# Make list of clean labels for columns
mtcars_labels = read.table(header=TRUE, text="
name label
model 'Model'
mpg 'Miles/(US) gallon'
cyl 'Number of cylinders'
disp 'Displacement (cu.in.)'
hp 'Gross horsepower'
drat 'Rear axle ratio'
wt 'Weight (1000 lbs)'
qsec '1/4 mile time'
vs 'Engine'
am 'Transmission'
gear 'Number of forward gears'
carb 'Number of carburetors'
")
# Apply column labels to mtcars
mydata = mtcars %>% import_labels(mtcars_labels, name_from="name", label_from="label")
crosstable(mydata,by=vs, test=TRUE, funs=c(mean=mean, "std error"=sd)) %>%
as_flextable()
以及它制作的表格的摘录:
CreateTableOne
也几乎是完美的,但我没有看到一种方法来使.tex或HTML输出。
1条答案
按热度按时间pxyaymoc1#
你的意思是这样的: