error in if (class(survivalTab1)==“matrix”){:the condition has length >1

img


请各位指导一下我这位初学者,这是出什么错了呀,我是跟着课程走的,但视频里走这一步走对了,我就怎么也走不过去,辛苦各位朋友了,请指导指导我吧

瞅瞅是不是
https://blog.csdn.net/zhongkeyuanchongqing/article/details/120616332

使用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