提问人:Ram193 提问时间:10/17/2023 最后编辑:neilfwsRam193 更新时间:10/17/2023 访问量:32
我正在尝试使用多个条件对数据集进行子集。当仅使用第一个条件时,它起作用,但当我添加第二个条件时则不然
I am trying to subset dataset with multiple conditions. It works when just the first condition is used, but not when I add the second condition
问:
具有第一个条件的子集的代码:
new <- subset(data, NDC == "L1000", select = GCharge:SelfPay)
summary(new)
GCharge SelfPay
Min. : 8513 Min. : 3235
1st Qu.:34306 1st Qu.:13036
Median :48279 Median :18346
Mean :42578 Mean :16180
3rd Qu.:53918 3rd Qu.:20489
Max. :56166 Max. :21343
第二个条件包含子集的代码:
newmed <- subset(data, NDC == "L1000" & PROCEDURE == "%like%MED",
select = GCharge:SelfPay)
GCharge SelfPay
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
我不知道为什么当“新”数据子集中没有 NA 时,会有第二个条件的 NA?
答: 暂无答案
评论