Skip to content

Instantly share code, notes, and snippets.

@jpfairbanks
Created October 25, 2018 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpfairbanks/a8032283d20e04c4c3c38b6b44dfe95b to your computer and use it in GitHub Desktop.
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
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