[R] filter one entry, in dependence of date

arun smartpink111 at yahoo.com
Wed Jul 23 22:07:32 CEST 2014


Hi,
If `dat` is the dataset:
dat[!(dat$ID==2 & as.numeric(gsub("-.*","",dat$Month))<5),]
  ID   Month Value
1  1 03-2014     1
2  1 04-2014    10
3  1 05-2014    50
6  2 05-2014     4
7  2 06-2014     2

A.K.



hello together, i have a short question, maybe you can help me.

I have a data.frame like this one
     ID    Month       Value
1    1     03-2014        1
2    1     04-2014        10
3    1     05-2014        50
4    2     03-2014         8
5    2     04-2014         7
6    2     05-2014         4
7    2     06-2014         2

I now want to create another data.frame without the lines from ID==2 which are earlier than 05-2014

The solution look like this one:

     ID    Month       Value
1    1     03-2014        1
2    1     04-2014        10
3    1     05-2014        50
4    2     05-2014         4
5    2     06-2014         2

maybe you can help me.

Best regards. Mat 




More information about the R-help mailing list