Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Extract rows where column greater than 40 [duplicate]

Tags:

r

Good day I have a data set I got from a txt file

> MyData
   Xdat Ydat
1  1    12
2  2    23
3  3    34
4  4    45
5  5    56
6  6    67
7  7    78

I need to use this set to extract rows that correspond to the case where the 2nd column(Ydat) is greater than 40. Resulting in MyData2

   Xdat Ydat
4  4    45
5  5    56
6  6    67
7  7    78
like image 869
Elzette Ford Avatar asked Sep 15 '14 18:09

Elzette Ford


1 Answers

Simple subsetting will do it -

MyData[which(MyData[,2]>40),]

as @DavidArenburg points out, this works fine:

MyData[(MyData[,2]>40),]
like image 86
jalapic Avatar answered Nov 15 '22 07:11

jalapic