Suppose I have an array with two columns. I want to filter
the array based on the values of the first column, but would like what is returned by filter
to include the second column. This method seems to be missing from filter
.
Example:
A = rand(100,2)
filter( x-> x[1]>0.5, eachrow(A))
ERROR: MethodError: no method matching filter(::var"#78#79", ::Base.Generator{Base.OneTo{Int64}, Base.var"#191#192"{Matrix{Float64}}})
I can do
map( x->x[1] > 0.5, eachrow(A))
But to do
A[ map( x->x[1] > 0.5, eachrow(A)), :]
seems cumbersome. Is there something I’m missing about filter
or eachrow
that would make the option directly using filter
work? Or was this method excluded for a reason I’m not seeing?