Reputation: 16064
In Rb given a vector x
one can find the indices where its elements are TRUE
using the which
function. E.g. y = 1:100
and which(is.even(y))
should return 2,4,...,100
There are also which.max
and which.min
which returns the indices of minimum and maximum values respectiely.
What are their equivalents in Julia?
Upvotes: 13
Views: 3453
Reputation: 2591
The equivalent of R's which is Julia's findall:
y = [1, 2, 3, 4]
findall(y .> 2)
Upvotes: 4
Reputation: 16064
There is no exact equivalent but findall
There is a comparison list of vocabularies for Julia vs R; which
is on the list
http://www.johnmyleswhite.com/notebook/2012/04/09/comparing-julia-and-rs-vocabularies/
However, according to the list Julia's find
is equivalent to R's which
as answered by others.
Upvotes: 5
Reputation: 134
The find
function does that.
In R:
y = c(1,2,3,4)
which(y > 2)
In Julia:
y = [1, 2, 3, 4]
find(y .> 2)
Upvotes: 10