将SAS proc格式转换为R [关闭](Convert SAS proc Format to R [closed])

编程入门 行业动态 更新时间:2024-10-24 19:26:56
将SAS proc格式转换为R [关闭](Convert SAS proc Format to R [closed])

我试图将SAS中的Proc Format语句转换为R.

proc format; value age_f 0='All Ages' 1='18-24' 2='25-34' 3='35-44' 4='45-54' 5='55-64' 6='65+';

我已经查看了R中的因子和级别,但我不知道如何实现,所以我可以稍后使用这些类别。

I am trying to convert a Proc Format statement in SAS to R.

proc format; value age_f 0='All Ages' 1='18-24' 2='25-34' 3='35-44' 4='45-54' 5='55-64' 6='65+';

I've looked in to the factor and the levels in R, but I am not sure how to implement then so I can use the categories later.

最满意答案

正如StatMethods链接所示,使用factor()方法将值标签与级别对齐:

mydata$age_f <- factor(mydata$age_f, levels = c(0, 1, 2, 3, 4, 5), labels = c("All Ages", "18-24", "25-34", "35-44", "45-54", "55-64"))

As the StatMethods link shows, use the factor() method to align value labels to levels:

mydata$age_f <- factor(mydata$age_f, levels = c(0, 1, 2, 3, 4, 5), labels = c("All Ages", "18-24", "25-34", "35-44", "45-54", "55-64"))

更多推荐

本文发布于:2023-08-01 18:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1363772.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   格式   proc   SAS   Format

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!