-1

Suppose, I have a list

a <- c(3, 5, 2, 7, 9)

and I want to do a vector operation, something like:

a_greater_than_five <- a[a>5]

but I want results something like below:

a_greater_than_five <- c(false, false, false, true, true).

Something similar to numpy in python: Check if all values in list are greater than a certain number

Community
  • 1
  • 1
Annie
  • 681
  • 7
  • 14

2 Answers2

2
>  a <- c(3, 5, 2, 7, 9)
> Result <- a>5
> Result
[1] FALSE FALSE FALSE  TRUE  TRUE
Sowmya S. Manian
  • 3,723
  • 3
  • 18
  • 30
1

If

 a <- c(3, 5, 2, 7, 9)

then simply

a > 5   
# [1] FALSE FALSE FALSE  TRUE  TRUE
Bryan Goggin
  • 2,449
  • 15
  • 17