[英]How to write an inequality in R
Sorry, I am an R newbie and I am having some difficulty抱歉,我是 R 新手,我遇到了一些困难
How would I write the following inequality in R:我将如何在 R 中编写以下不等式:
x > 10 is twice more likely than x < 10 x > 10 的可能性是 x < 10 的两倍
I tried this function and it didn't work:我试过这个 function 但没有用:
X = 10
f = function(X,Y) {
if ((2(X) >= 10 & X <= 10) {
print("in range")
} else {
print("out of range")
}
}
Your code has a syntax error if that's the problem:如果这是问题所在,您的代码有语法错误:
X = 10
f = function(X,Y) {
if (2 * X >= 10 && X <= 10) { # * instead of (
print("in range")
} else {
print("out of range")
}
}
You can try your function as in:您可以尝试您的 function,如下所示:
> f(10,10) [1] "in range" > f(20,10) [1] "out of range"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.