Jonas Zerbib
Jonas Zerbib

Reputation: 85

How select rows of my vector with conditions in R?

I have a vector with values ​​between 0 and 1 (the name of my vector is pvals) and I would like to keep the elements of my vector pvals which respect the condition:

pvals(i) < i/m*alpha

where alpha = 0.05 and m = 1000 (the size of my vector pvals)

how can i do please? here i create my pvals vector, and indexes i, but after that i don't know how to make what i explained above:

pvals = runif(1000, 0, 1)
i = seq(along=pvals)

Upvotes: 1

Views: 592

Answers (1)

Joshua Mire
Joshua Mire

Reputation: 736

Based on your described question, this should work.

If m and alpha exist outside of pvals:

pvals<-pvals[pvals$i < pvals$i/m*alpha,]

I hope this helps!

Upvotes: 1

Related Questions