Are there functions like `filterslices`

or `selectslices`

to do the below.

```
X =[
1 1 1 1
1 missing 1 1
1 missing missing 1
1 1 1 missing
]
i = mapslices( x-> count(ismissing,x) ≤1, X , dims=1)[1,:]
X[:,i]
#something like this to do the above
filterslices( x-> count(ismissing,x) ≤1, X, dims=1 )
```

Maybe these are slightly more readable?

```
stack(filter(x->count(ismissing,x)<=1, eachcol(X)))
stack(x for x in eachcol(X) if count(ismissing,x)<=1) # Iterators.filter
```

3 Likes

other possibility:

```
X[:,findall(x-> count(ismissing,x)<=1,eachcol(X))]
```

and this too (although not very beautiful and efficient)

```
[filter(x-> count(ismissing,x)<=1,eachcol(X))... ;;]
```

1 Like

```
using AccessorsExtra
@modify(eachcol(X)) do cols
filter(x -> count(ismissing, x) ≤ 1, cols)
end
```

works with eachrow and eachslice as well, not just eachcol.

2 Likes

Thanks all. Very useful

Its actually cleaner with a KeyedArray

```
X = KeyedArray( [
#b1 #b2
1;1;0;1;; 1;0;1;1;;; #c1
1;0;1;1;; 1;1;1;1;;; #c2
1;1;0;1;; 1;1;1;1 #c3
], a=1:4, b=[:b1,:b2], c=[:c1,:c2,:c3] )
X(c = [i for i in X.c if count(iszero, X(c=i)) ≤ 1 ] )
```

1 Like