如何做基线表rm(list =ls()) setwd("C:\\Users\\17657\\Desktop\\ska3") options(repos='') library(xlsx) baseline<- ('临床信息.xlsx',sheetIndex = 1,header = T,encoding = 'UTF-8') baseline<-baseline[1:1096,] base<-subset(baseline,select = c(age,T,M,N,stage,ER,PR,HER2,subtype)) Freq<-lapply(base[,1:9],table) prop<-lapply(Freq[1:9],) prop character<-c(names(Freq[1]),names(Freq[[1]])) Noc<-c(NA,paste0(Freq[[1]],'(',prop[[1]],')')) char<-NULL characteristics<('characteristics'=character,' number of class'=Noc) for (i in 1:9) {character<-c(names(Freq[i]),names(Freq[[i]])) Noc<-c(NA,paste0(Freq[[i]],'(',prop[[i]]*100,')')) characteristics<('characteristics'=character,' number of class(%)'=Noc) char<-rbind(char,characteristics) } (char,'基线表.xlsx',)好啦可以啦~