I would like to separate my data based on one column (Column B in below data). In other words, I like to separate rows with 'C' letter that they has same number before letter 'c' with others rows (letters,a and b imply to parents ,and c implies to children, I like to remove children from same family).
Input:
df <- structure(list(
A = c("L", "L","L","L","L","L","L", "L", "L"),
B = c("l-7b", "l-7a", "l-7c", NA, "l-15a", "l-15c", "l-16c", "l-20b", "l-20c"),
C = c(6002, 6003, 6006,6007,6010,6011,6015, 6087, 6098)),
.Names = c("A", "B", "C"),
row.names = c(NA, 9L),
class = "data.frame")}
Output:
A B C
1 L l-7b 6002
2 L l-7a 6003
4 L NA 6007
5 L l-15a 6010
7 L l-16c 6015
8 L l-20b 6087