Warning message: the condition has length > 1 and only the first element will be used
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
Warning message:In if (x > 1) { :the condition has length > 1 and only the first element will be used
目录
问题:
#想把向量中元素大于1的乘以2;
#如下方法把所有的元素都乘以了2
#define data
x <- c(2, 3, 1, 1, 5, 7)
#if value in vector x is greater than 1, multiply it by 2
if (x>1) {
x*2
}
[1] 4 6 2 2 10 14
解决:
#使用ifelse语法
#if value in vector x is greater than 1, multiply it by 2
ifelse(x>1, x*2, x)
[1] 4 6 1 1 10 14
完整问题:
> #define data
> x <- c(2, 3, 1, 1, 5, 7)
>
> #if value in vector x is greater than 1, multiply it by 2
> if (x>1) {
+ x*2
+ }
[1] 4 6 2 2 10 14
Warning message:
In if (x > 1) { :
the condition has length > 1 and only the first element will be used
参考:R
参考:How to Fix in R: the condition has length > 1 and only the first element will be used
GitHub 加速计划 / eleme / element
10
1
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:5 个月前 )
c345bb45
9 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 9 个月前
更多推荐
已为社区贡献11条内容
所有评论(0)