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
Simple subsetting will do it -
MyData[which(MyData[,2]>40),]
as @DavidArenburg points out, this works fine:
MyData[(MyData[,2]>40),]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With