R - argument is of length zero in if statement

后端 未结 6 1732
别那么骄傲
别那么骄傲 2020-11-28 07:39

I am having a little problem with R and I am not sure why. It is telling me that this line: if(temp > data[[k]][[k2]]) { is of argument length 0. Here is the

6条回答
  •  离开以前
    2020-11-28 07:51

    You can use isTRUE for such cases. isTRUE is the same as { is.logical(x) && length(x) == 1 && !is.na(x) && x }

    If you use shiny there you could use isTruthy which covers the following cases:

    • FALSE

    • NULL

    • ""

    • An empty atomic vector

    • An atomic vector that contains only missing values

    • A logical vector that contains all FALSE or missing values

    • An object of class "try-error"

    • A value that represents an unclicked actionButton()

提交回复
热议问题