rfresco

1. Create a sequence of number from 10 and 20 and assign it to variable M. 2.Identify the position of values greater than 13 and less than 20


I have tried below code , but it is showing not accurate answers

M = seq(10,20)
print(which(M > 13 & M<20))

Solution

  • Your code is correctly showing position of elements. See?

    > print(which(M > 13 & M<20))
    [1]  5  6  7  8  9 10   <-- position of elements
    
    > M[which(M > 13 & M<20)]
    [1] 14 15 16 17 18 19   <-- actual values