The following code will produce a warning in R

Untitled Forums Statistics R programming The following code will produce a warning in R

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15892
    nammy
    Participant

    The following code will produce a warning in R.
    x <- 1:10

    if(x > 5) {

    x <- 0

    }
    Why?

    1. ‘x’ is a vector of length 10 and ‘if’ can only test a single logical statement.
    2. The expression uses curly braces.
    3. The syntax of this R expression is incorrect.
    4. You cannot set ‘x’ to be 0 because ‘x’ is a vector and 0 is a scalar.
    5. There are no elements in ‘x’ that are greater than 5
    #15893
    nammy
    Participant

    Answer:-1
    ‘x’ is a vector of length 10 and ‘if’ can only test a single logical statement.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.