1

I have the following problem within R:

I'm working with a huge matrix. Some of the columns contain the value 'zero', which leads to problems during my further work.

Hence, I want to identify the columns, which contain at least one value of 'zero'.

Any ideas how to do it?

0

2 Answers 2

2

If you have a big matrix then this would be probably faster than an apply solution: mat[,colSums(mat==0)<0.5]

Sign up to request clarification or add additional context in comments.

Comments

0

lets say your matrix is called x,

x = matrix(runif(300), nrow=10)

to get the indices of the columns that have at least 1 zero:

ix = apply(x, MARGIN=2, function(col){any(col==0)})

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.