I am trying to remove the groups from my dataset using data.table. I already have a vector containing all the groups that I want to keep:
group_vector <- c(1001, 2800, 3230, 4600)
This is my current dataframe:
structure(list(group = c(1001, 2025, 2800, 2900, 3012, 3230,
4600), values = c(10, 24, 23, 21, 41, 32, 34)), class = c("data.table",
"data.frame"), row.names = c(NA, -7L))
group values
1: 1001 10
2: 2025 24
3: 2800 23
4: 2900 21
5: 3012 41
6: 3230 32
7: 4600 34
My desired output:
group values
1: 1001 10
2: 2800 23
3: 3230 32
4: 4600 34
How would I go about doing this? It is a large dataset hence the need to use data.table syntax.