Created
October 25, 2018 13:47
-
-
Save jpfairbanks/a8032283d20e04c4c3c38b6b44dfe95b to your computer and use it in GitHub Desktop.
A function to delete rows from an array based on equality among the columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A = readdlm("filename.csv") | |
function droprows(A::AbstractMatrix, r) | |
keeprows = Int[] | |
for i in 1:size(A,1) | |
if A[i,r[1]] == A[i,r[2]] == A[i,r[3]] | |
continue | |
else | |
push!(keeprows, i) | |
end | |
end | |
@show keeprows | |
B = A[keeprows,:] | |
return B | |
end | |
droprows(A, [10,11,12]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment