2016-12-27 25 views
-1

私は将来の日付2099-01-01のプロキシを持つdata.frameと欠落したデータを持っています。私は、NAsも取り除かずに、将来の日付だけをフィルタリングしようとしています。私はNAを削除しないフィルタ

inactive1 <- filter(`Latest Active Date` < "2099-01-01")` 

を試してみたが、

inactive1 <- filter(`Latest Active Date` != "2099-01-01") 

任意の提案はありませんので、これは、同様のNAを削除しますか?

あなたの質問で提案されているように dplyrから filterを使用して
test3 <- structure(list(`EI Program Type` = c("EI - Infant/Toddler", "EI - Infant/Toddler","EI - Infant/Toddler", "EI - Infant/Toddler", "EI - Infant/Toddler","EI - Infant/Toddler", "EI - Infant/Toddler", "EI - Infant/Toddler","EI - Infant/Toddler", "EI - Infant/Toddler"), `MCI ID` = c("770328087","570325112", "990627838", "070302077", "710347653", "250277177","470381260", "600330482", "270264208", "391186487"), `Record Status` = c("Inactive","Inactive", "Inactive", "Inactive", "Inactive", "Inactive", "Inactive","Inactive", "Inactive", "Inactive"), `Detail/ Reason` = c("Part B eligibility not determined (<33 months)","Successful completion of plan (IFSP/IEP)", "Successful completion of plan (IFSP/IEP)","Eligible for IDEA Part B (<33 months)", "PELICAN EI Data Correction","Not eligible for Part B - referrals (<33 months)", "Parent declined EI services","Eligible for IDEA Part B (<33 months)", "Eligible for IDEA Part B (<33 months)","Attempts to contact unsuccessful"), `Effective Begin Date` = structure(c(16049,16021, 15561, 16173, 17106, 15666, 16217, 16749, 15968, 16560), class = "Date"), `Effective End Date` = structure(c(47117,16146, 47117, 47117, 47117, 47117, 47117, 16772, 47117, 16700), class = "Date"), `Case Closure Date` = structure(c(16039,15991, 15546, 16166, 17062, 15589, 16210, 16738, 15909, 16553), class = "Date"), `Latest Active End Date` = structure(c(15882,16177, 15341, 16084, 16602, 15537, NA, 16784, 15744, 17030), class = "Date")), .Names = c("EI Program Type","MCI ID", "Record Status", "Detail/ Reason", "Effective Begin Date","Effective End Date", "Case Closure Date", "Latest Active End Date"), row.names = c(360065L, 493021L, 118486L, 448679L, 673846L,206565L, 914550L, 756388L, 297259L, 853157L), class = "data.frame") 
+1

あなたのテストデータが含まれており、2099年1月1日の日付をしていないようです。 – G5W

+6

'サブセット(test1、!(最新のアクティブ終了日\' == as.POSIXct( "2099-01-01"、tz = "UTC")&!is.na(\ ))) ' – Roland

答えて

-1

library(dplyr) 
filter(test1, `Latest Active End Date` < "2099-01-01" | is.na(`Latest Active End Date`)) 
+0

これは私にとってはうまくいかなかったようです。コードは直感的ですが何らかの理由ですべてのケースが残っていました。 –

+0

@ JeremyR.Johnson、問題を再現できるように将来の日付を 'test1'に追加できますか?ありがとう! – Thales

+0

将来の日付とNAsを含むように更新されました。 –

関連する問題