[R] Subseting a data.frame

Katherine Gobin
Thu, 17 Oct 2013 06:55:34 -0000

Dear Forum,

I have a data frame as

mydat = data.frame(basel_asset_class = c(2, 8, 8 ,8), defa_frequency = c(0.15,
0.07, 0.03, 0.001))

> mydat
  basel_asset_class defa_frequency
1                 2          0.150
2                 8          0.070
3                 8          0.030
4                 8          0.001


I need to get the subset of this data.frame where no of records for the given
basel_asset_class is > 2, i.e. I need to obtain subset of above data.frame as
(since there is only 1 record, against basel_asset_class = 2, I want to filter
it)

> mydat_a
  basel_asset_class defa_frequency
1                 8          0.070
2                 8          0.030
3                 8          0.001

Kindly guide

Katherine