0

My problem is this:

A table containing different values and what I need is to eliminate the singletons (rowSums = 1) and dobletons (rowSums = 2) at the same time without need to repeat the steps.

Name    samp1   samp2   samp3   samp4
A   1.00    4.92    3.34    56.90
B   1.97    3.96    8.65    2.79
C   1.00    0.00    0.00    0.00
D   1.70    4.32    3.97    3.37
E   0.00    0.00    2.00    0.00

I first tried this to eliminate singletons

data = read.table(file="XXX", header = TRUE,  row.names=1)
data_no_singletons = data[rowSums(data)!=1,]
data_no_dobletons = data_no_singletons[rowSums(data_no_singletons)!=2,]

Is it possible to eliminate the rows using both conditions at the same time to get this table?

Name    samp1   samp2   samp3   samp4
A   1.00    4.92    3.34    56.90
B   1.97    3.96    8.65    2.79
D   1.70    4.32    3.97    3.37

SOLVED Include ">2" and that`s all

data_cleaned = data[rowSums(data)> 2,]
lmo
  • 37,904
  • 9
  • 56
  • 69
F.Lira
  • 663
  • 2
  • 6
  • 19
  • 1
    In addition to inequalities like `rowSums(data) != 1`, you can use inequalities like `rowSums(data) > 2`. This is probably best in your situation. – Gregor Thomas Feb 15 '17 at 18:38
  • 2
    would `data[ -(rowSums(data) %in% c(1,2)), ]` do the trick? It would keep only rows where the sum is not 1 or 2. – Jealie Feb 15 '17 at 18:40

0 Answers0