简体   繁体   English

如何在 R 中对表 1 function 中的行进行子集化?

[英]How to subset rows in table1 function in R?

I want to make a table using the same data source and columns but creating a subset of data for one of the columns (excluding "Large").我想使用相同的数据源和列创建一个表,但为其中一个列创建数据子集(不包括“大”)。

table1::label(data$Fraction != "Large")<-"Fraction all except large"
table1::label(data$Fraction)<-"Fraction all"
table1::table1(~Fraction+
               ~Fraction
                 | Location, data = data, transpose = F)

Assuming that "data" is a data.frame or similar (your example is not clear there), subset your data first:假设“数据”是一个 data.frame 或类似的(你的例子不清楚),首先对你的数据进行子集化:

datasubset <- subset(data, data$Fraction != "Large")

Only then plug it into table1 for formatting/exporting or whatever you're doing with that.只有然后将其插入 table1 以进行格式化/导出或您正在做的任何事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM