Aamir Khan Aamir Khan - 3 months ago 8
R Question

Alternate to match function in R that returns list of indexes

I am using

R 3.5


I want to get all indexes that contain zero in my list

a = c(1,2,3,0,5,7,0)


result should be

[1] 4 7


should return the indexes as
match
will only return the first index in this case
4

Answer

You shoud read about function which:

> a = c(1,2,3,0,5,7,0)
> which(a == 0)
[1] 4 7