Question

I would like to subset all lines which have "chr" column from 1 to 29, in a "cnv1" dataframe.

I tried it:

cnvk <- cnv1[cnv1$chr==1:29,]

But it do not get all lines which have 1,2,3...29.

Cheers!

Was it helpful?

Solution

Try

cnvk <- cnv1[cnv1$chr %in% 1:29,]

or

cnvk <- cnv1[cnv1$chr>=1 & cnv1$chr<=29,]

(The latter might be quicker if you're checking against a large range of values)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top