I'm not entirely sure what your expected output should be (or what assets
is). If you are just needing to create subsets of your dataframe and put them into a list, then we can use lapply
or purrr
.
lapply(c(1:10), function(x) {
df[df$RP_ENTITY_ID == x,]
})
Or using purrr
:
library(tidverse)
map(c(1:10), function(x) {
df %>% filter(RP_ENTITY_ID == x)
})
Output
[[1]]
RP_ENTITY_ID b c
1 1 200 51
[[2]]
RP_ENTITY_ID b c
1 2 199 52
[[3]]
RP_ENTITY_ID b c
1 3 198 53
[[4]]
RP_ENTITY_ID b c
1 4 197 54
[[5]]
RP_ENTITY_ID b c
1 5 196 55
[[6]]
RP_ENTITY_ID b c
1 6 195 56
[[7]]
RP_ENTITY_ID b c
1 7 194 57
[[8]]
RP_ENTITY_ID b c
1 8 193 58
[[9]]
RP_ENTITY_ID b c
1 9 192 59
[[10]]
RP_ENTITY_ID b c
1 10 191 60
Data
df <-
structure(
list(
RP_ENTITY_ID = 1:100,
b = 200:101,
c = 51:150
),
class = "data.frame",
row.names = c(NA,-100L)
)