Hi Team
I hope you will help me in this to classify emergency patient types by looking at the col 1 and 3.
The expected result would be the col 4 ed_ip_split_2 .
ed_only (NA in col 3 if_admitted_id and EDxxxx prefix in col 1 ed_ip_id),
ed_admit (ed_ip_id with prefix ED and IPxxxxx populated in col 3 if_admitted_id), and
ip_only (both col 1 and 3 populated with IPxxxxx prefix).
Repex is here.
Thank you very much.
# ed ip split
ed_ip_data = tibble::tribble(
~ed_ip_id, ~ed_ip_split, ~if_admitted_id, ~ed_ip_split_2,
"ED1700147", "ED", NA, "ed_only",
"ED1700147", "ED", NA, "ed_only",
"ED1698078", "ED", "IP04218624", "ed_admit",
"ED1698078", "ED", "IP04218624", "ed_admit",
"ED1698078", "ED", "IP04218624", "ed_admit",
"ED1698078", "ED", "IP04218624", "ed_admit",
"IP04229022", "IP", "IP04229022", "ip_only",
"IP04229022", "IP", "IP04229022", "ip_only",
"IP04229022", "IP", "IP04229022", "ip_only",
"IP04229022", "IP", "IP04229022", "ip_only"
)
ed_ip_data
#> # A tibble: 10 x 4
#> ed_ip_id ed_ip_split if_admitted_id ed_ip_split_2
#> <chr> <chr> <chr> <chr>
#> 1 ED1700147 ED NA ed_only
#> 2 ED1700147 ED NA ed_only
#> 3 ED1698078 ED IP04218624 ed_admit
#> 4 ED1698078 ED IP04218624 ed_admit
#> 5 ED1698078 ED IP04218624 ed_admit
#> 6 ED1698078 ED IP04218624 ed_admit
#> 7 IP04229022 IP IP04229022 ip_only
#> 8 IP04229022 IP IP04229022 ip_only
#> 9 IP04229022 IP IP04229022 ip_only
#> 10 IP04229022 IP IP04229022 ip_only