当前位置:网站首页>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过程,改变了原始内容?】

边栏推荐
- Leetcode 1108 IP address invalidation [violence] the leetcode path of heroding
- RT thread persimmon pie M7 Quanzhi f133 DDR running xboot
- EtherCAT igh master station controls three Delta asdaa2 servo rotating circles
- SQL操作:WITH表达式及其应用
- EtherCAT igh主站控制3个台达asdaa2伺服转圈圈
- RT-Thread 柿饼派M7 全志F133 ddr 运行xboot
- 使用tidevice启动WDA
- 搜索(集训)
- LeetCode 1108 IP地址无效化[暴力] HERODING的LeetCode之路
- Compound type of typescript
猜你喜欢

Operation of simulation test platform for test questions bank of R1 quick opening pressure vessel operation certificate in 2022

Development of digital collection system and construction of NFT artwork trading platform

TypeScript的类型检查

Node output mode

RK3566调试GC2053

是关于Linux中一步建立yum源缓存问题

Server socket program

EtherCAT master station based on am4377 controls STM32 slave station

SQL操作:WITH表达式及其应用

TypeScript的一些基本特征
随机推荐
Can I use line as a product term in the cable industry? Generally not used
Node modular management
让接口自动化测试灵动起来
字节流量生意经:变现趁早、缝钱袋子、All in卖货
Node的url模块
SQL操作:WITH表达式及其应用
EtherCAT igh源码的ecrt_slave_config_dc()函数的理解。
基于mitmproxy的录制回放接口测试工具
剑指 Offer 12. 矩阵中的路径
How typescript is constructed
RMB 18billion, a super master fund was born in Suzhou
电缆行业产品词可以用line吗?一般不用
Some basic features of typescript
TypeScript的类型检查
剑指offer 58.对称的二叉树
markdown写作软件:Ulysses v27
What is the S3 protocol that we are talking about every day? This article takes you to understand the story behind S3
怎么安装 Laravel
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)
剑指 Offer 28. 对称的二叉树