我面临着一个挑战,在创建分页后,每16行考虑类别和子类别。假设我们有如下的数据,其中category是row_label1
,sub_category是row_label2
。
我已经为每16行创建了一个组作为增量。
structure(list(row_label1 = c("Age (years)", "Age (years)", "Age (years)",
"Age (years)", "Age range, n(%)", "Age range, n(%)", "Age range, n(%)",
"Race, n(%)", "Race, n(%)", "Race, n(%)", "Gender, n(%)", "Gender, n(%)",
"Ethnicity, n(%)", "Ethnicity, n(%)", "Height (cm)", "Height (cm)",
"Height (cm)", "Height (cm)", "Weight (kg)", "Weight (kg)", "Weight (kg)",
"Weight (kg)", "Body Mass Index (kg/m2)", "Body Mass Index (kg/m2)",
"Body Mass Index (kg/m2)", "Body Mass Index (kg/m2)", "BMI (kg/m2)",
"BMI (kg/m2)", "BMI (kg/m2)"), row_label2 = c("n", "Mean (SD)",
"Median", "Min, Max", "<65", "65-80", ">80", "WHITE", "BLACK OR AFRICAN AMERICAN",
"AMERICAN INDIAN OR ALASKA NATIVE", "Female", "Male", "Hispanic or latino",
"Not hispanic or latino", "n", "Mean (SD)", "Median", "Min, Max",
"n", "Mean (SD)", "Median", "Min, Max", "n", "Mean (SD)", "Median",
"Min, Max", "<25", "25-<30", ">=30"), groups = c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L)), row.names = c(NA, -29L
), class = c("tbl_df", "tbl", "data.frame"))
我想创建一个新的变量,也考虑到类别和子类别,然后递增的数量,使类别和子类别之间不分裂2页
现在我想有新的变量增加考虑到16行,但与类别和子类别不应该分裂。因此,在新变量中,数字2应该在Height之前开始,尽管考虑到类别和子类别,它缺少16行
我期待一个页面变量的东西如下
1条答案
按热度按时间eh57zj3b1#
关于this post: