Everyone,
I need a programmatic method to first select observations from a tibble and then interactively to subset that tibble into multiple "child" tibbles.
I haven't been able to find a method that is completely programmatic with NO human interaction during the selecting and sub-setting steps.
Does anyone have any suggestions, please?
Thanks in advance for sharing your knowledge and experience.
Linda
# I want to use a programmatic method to use each element of a vector (termination_id_vector)
# to select observations from a tibble (master_tibble)
# and then iteratively to subset the tibble into multiple child tibbles (child_tibbleX56666, etc).
# i = 1 to 4
termination_id_vector <- c("X56666", "X98453", "X09916", "X11446")
# The table to be subsetted iteratively into i separate tables
master_tibble <- tibble::tribble(
~ID, ~status,
"X56666", "ORIGINATION",
"X56666", "CONTINUATION",
"X56666", "TERMINATION",
"X98453", "ORIGINATION",
"X98453", "TERMINATION",
"X09916", "ORIGINATION",
"X09916", "TERMINATION",
"X11446", "ORIGINATION",
"X11446", "TERMINATION",
"X11111", "ORIGINATION",
"X11111", "CONTINUATION"
)
# the four output tables (number = i) that I need to obtain programmatically:
# i=1
child_tibbleX56666 <- tibble::tribble(
~ID, ~status,
"X56666", "ORIGINATION",
"X56666", "CONTINUATION",
"X56666", "TERMINATION"
)
head(child_tibbleX56666)
# i=2
child_tibbleX98453 <- tibble::tribble(
~ID, ~status,
"X98453", "ORIGINATION",
"X98453", "TERMINATION"
)
head(child_tibbleX98453)
# i=3
child_tibbleX09916 <- tibble::tribble(
~ID, ~status,
"X09916", "ORIGINATION",
"X09916", "TERMINATION"
)
head(child_tibbleX09916)
# i=4
child_tibbleX11446 <- tibble::tribble(
~ID, ~status,
"X11446", "ORIGINATION",
"X11446", "TERMINATION"
)
head(child_tibbleX11446)