当前位置:网站首页>R语言 bug?报错?关于亚变量0、1 结局outcome,outcome变量经过factor和numeric过程,改变了原始内容?
R语言 bug?报错?关于亚变量0、1 结局outcome,outcome变量经过factor和numeric过程,改变了原始内容?
2022-06-21 16:59:00 【违规账号247188】
问题RT
因为我在做PSM的逆概率加权和匹配法,和做表格时的卡方检验,他们对结局的变量的类型要求是不同的,我在转化过程中,发现outcome内容 0 1变成 12 ,虽然他们是0=1 、1=2的转化影响不大,但是我在分层提取 outcome=0时,想提取对照组,发现没有对应的数据。所以这个bug是如何产生的?
data <- iris #鸢尾花
data$outcome <- rep(0:1,each=75)
table(data$outcome)
str(data$outcome)
#outcome因子化
data$outcome <- as.factor(data$outcome)
table(data$outcome) #此时outcome还是 0和1
str(data$outcome)
#outcome继续转为数值型
data$outcome <- as.numeric(data$outcome)
table(data$outcome) #这时候发现outcome 01亚变量变成了1和2
str(data$outcome)
#【问题,outcome变量经过factor和numeric过程,改变了原始内容?】

边栏推荐
- EtherCAT对象字典分析
- Typescript compilation generation file comparison
- Check information on the Internet after the college entrance examination, and pay attention to prevent websites without SSL certificates
- 2022 high altitude installation, maintenance and removal work license question bank and simulated examination
- JZ59.按之字型顺序打印二叉树
- EtherCAT master station based on am4377 controls STM32 slave station
- SQL操作:WITH表达式及其应用
- POSIX create terminate thread
- Leetcode 1108 IP address invalidation [violence] the leetcode path of heroding
- Laravel实现文件(图片)上传
猜你喜欢

Character processing of node

Paper notes ACL 2022 unified structure generation for universal information extraction

AI writes its own code to let agents evolve! The big model of openai has the flavor of "human thought"

TypeScript的类型检查

TypeScript类对象的初始化

Global installation of node

EtherCAT igh主站控制3个台达asdaa2伺服转圈圈

缓存型数据库Redis的配置与优化

带你区分几种并行

Under the banana whose R & D accounts for only 3%, is it sunscreen black technology or IQ tax in summer?
随机推荐
搜索(集训)
研发仅占3%的蕉下,是防晒黑科技,还是夏天的智商税?
CentOS使用composer install 报错 - phpunitphpunit 8
ByteDance proposes a lightweight and efficient new network mocovit, which has better performance than GhostNet and mobilenetv3 in CV tasks such as classification and detection!
快速失败和安全失败的区别
国产API管理平台横向比较,到底哪家强?
Structural modeling and Design -- a practical summary of the functions of rotary cutting and fillet chamfering in feature forming of SolidWorks software (drawing a countersunk screw hole)
服务端socket程序
会议聊天室--开发文档
Byte Jump propose un nouveau type de réseau léger et efficace, mobovit, qui surpasse GhostNet et mobilenetv3 dans la classification, la détection et d'autres tâches CV!
System V IPC与POSIX IPC
Node的json解析
EtherCAT igh master station controls three Delta asdaa2 servo rotating circles
Move Protocol Beta测试版稳定,临时决定奖池规模再扩大
Mysql常见面试题
What is the S3 protocol that we are talking about every day? This article takes you to understand the story behind S3
AWS Device Shadow使用
Typescript的复合类型
Postman association to complete interface automation test
Node模块化管理