R语言笔记-用tableStack汇总双变量分析结果


示例数据: MASS包中的 birthwt数据集。

预处理

  • 将分类变量因子化,具体参考这里
  • 为每个变量设置标签:语法为attr(数据框名,"var.labels")<-c(按变量顺序排列的标签名)
> attr(birthwt,"var.labels")<-c("low birth weight","mother's age(yr)","mother's weight(lbs)","mother's race","smoking status","number of premature births","history of HTN","uterine irritability","number of physician visits","birth weight(g)")
> des(birthwt) # 该函数位于epiDisplay包中
 
 No. of observations =  189 
   Variable      Class           Description               
1  low           factor          low birth weight          
2  age           integer         mother's age(yr)          
3  lwt           integer         mother's weight(lbs)      
4  race          factor          mother's race             
5  smoke         factor          smoking status            
6  ptl           integer         number of premature births
7  ht            factor          history of HTN            
8  ui            factor          uterine irritability      
9  ftv           integer         number of physician visits
10 bwt           integer         birth weight(g)           
<
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值