我希望r中的功能检查一个列的值是否大于第75分位数,然后在下一个列中写入是或否
我已经尝试了以下公式,但是即使我更改分数值,也可以提供所有NOS。 注意:我有3个独立数据集,我想应用该功能。
outlier<-function(x1,x2){
q1<-quantile(x1 , .75, na.rm = TRUE)
if(x1>q1){x2<-"Yes"
}else{
x2<-"No"
}
}
我尝试了x2&lt; -ifelse(x1&gt; q1,“ yes”,“ no”)
在功能内部,但仍然不起作用。
I have tried the following formula but it gives all nos even when I change the quantile value.
NOTE: I have 3 independent datasets that I want to apply the function.
outlier<-function(x1,x2){
q1<-quantile(x1 , .75, na.rm = TRUE)
if(x1>q1){x2<-"Yes"
}else{
x2<-"No"
}
}
I have tried x2<-ifelse(x1>q1,"Yes","No")
inside the function but it still doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
ifelse
语句,并使用Mutate
创建一个新列。如果您想要功能
You can use an
ifelse
statement and create a new column usingmutate
.If you want a function