2017-11-24 2 views
0

ETAが「5営業日」、2営業日が「8営業日」の場合を除き、すべてを保持する必要のあるデータセットがあります。 'Booking Date' 10月31日私はこれがgrep機能を含むことは間違いないと確信していますが、私はそのような条件でそれをどうやって行うのか分かりません。2列の特定の行の例外を含むデータフレーム内のすべてのデータを保持

私の元のデータセットは、さらに多くの変数と14列を持っていますが、ここではサンプルです....

感謝どのような援助を:)

DF 
 
Booking Date  ETA     Address 
 
8th October   4 business days  1 Lane Drive 
 
30th October  5 business days  2 Daisy Rd 
 
31st October  1 business day  5 Bay St 
 
31st October  8 business days  10 Charlotte St

答えて

0

・ホープ、このことができます!

library(dplyr) 
df %>% 
    filter(!(Booking_Date %in% c('30th October','31st October') & 
      ETA %in% c('5 business days','8 business days'))) 

出力は次のとおりです。

Booking_Date    ETA  Address 
1 8th October 4 business days 1 Lane Drive 
2 31st October 1 business day  5 Bay St 


#sample data 
> dput(df) 
structure(list(Booking_Date = structure(c(3L, 1L, 2L, 2L), .Label = c("30th October", 
"31st October", "8th October"), class = "factor"), ETA = structure(c(2L, 
3L, 1L, 4L), .Label = c("1 business day", "4 business days", 
"5 business days", "8 business days"), class = "factor"), Address = structure(c(1L, 
3L, 4L, 2L), .Label = c("1 Lane Drive", "10 Charlotte St", "2 Daisy Rd", 
"5 Bay St"), class = "factor")), .Names = c("Booking_Date", "ETA", 
"Address"), class = "data.frame", row.names = c(NA, -4L)) 
関連する問題