子行我有一个有趣的过滤器的问题。对于每个TEI,我需要检查它是否存在于任何CHILDREN_LIST中,以及它是否删除存在的父行。过滤掉父行如果存在
例如:TEI 611100存在于CHILDREN_LIST的TEI 611000所以我需要删除611000行。
这里是dput()为表。谢谢!
structure(list(TEI = c(611000L, 611100L, 238000L, 452000L, 561000L,
621000L, 622000L, 622100L, 623000L, 722000L, 722500L, 722510L
), OWNERSHIP = c(30L, 30L, 50L, 50L, 50L, 50L, 50L, 50L, 50L,
50L, 50L, 50L), RESULT = c(266.9, 259.5, 138, 103.3, 105.8, 130,
230, 214.1, 171.9, 204, 185.2, 185.2), CODE = c(3L, 4L, 3L, 3L,
3L, 3L, 3L, 4L, 3L, 3L, 4L, 5L), CHILDREN_LIST = structure(c(4L,
NA, 1L, 2L, 3L, 5L, 6L, NA, 7L, 8L, 9L, 10L), .Label = c("238100 238200 238300 238900",
"452100 452900", "561100 561200 561300 561400 561500 561600 561700 561900",
"611100 611200", "621100 621200 621300 621400 621500 621600 621900",
"622100 622200 622300", "623100 623200 623300 623900", "722300 722400 722500",
"722510", "722511 722513 722514 722515"), class = "factor"),
ESTIMATE_TYPE = c(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE), NAICS_LABEL = c(611, 6111,
238, 452, 561, 621, 622, 6221, 623, 722, 7225, 72251), NAICS_TITLE = structure(c(3L,
4L, 11L, 7L, 1L, 2L, 8L, 6L, 9L, 5L, 10L, 10L), .Label = c("Administrative and support services",
"Ambulatory health care services", "Educational services",
"Elementary and secondary schools", "Food services and drinking places",
"General medical and surgical hospitals", "General merchandise stores",
"Hospitals", "Nursing and residential care facilities", "Restaurants",
"Specialty trade contractors"), class = "factor")), .Names = c("TEI",
"OWNERSHIP", "RESULT", "CODE", "CHILDREN_LIST", "ESTIMATE_TYPE",
"NAICS_LABEL", "NAICS_TITLE"), row.names = c(NA, 12L), class = "data.frame")
真棒响应!谢谢。 – Michael