antibiotic_type | route
ciprofloxacin | IV
ciprofloxacin | PO
doxycycline | IV
doxycycline | PO
penicillin | IV
penicillin | IV
doxycycline | PO
doxycycline | PO
penicillin | IV
penicillin | IV
I want to delete "PO" from the whole column.
Hi @Bishwaraj_Deo , could you put a reproducible example for understand better the situation:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
d_i_b_w <- df
antibiotic_type <- ciprofloxacin, ciprofloxacin, doxycycline, doxycycline, penicillin, penicillin
route <- IV, PO, IV, PO, IV, IV
You need something like this?
example_data <- data.frame(antibiotic_type = c("ciprofloxacin", "ciprofloxacin", "doxycycline", "doxycycline", "penicillin", "penicillin", "doxycycline", "doxycycline", "penicillin", "penicillin"),
route = c("IV", "PO", "IV", "PO", "IV", "IV", "PO", "PO", "IV", "IV"))
example_data
#> antibiotic_type route
#> 1 ciprofloxacin IV
#> 2 ciprofloxacin PO
#> 3 doxycycline IV
#> 4 doxycycline PO
#> 5 penicillin IV
#> 6 penicillin IV
#> 7 doxycycline PO
#> 8 doxycycline PO
#> 9 penicillin IV
#> 10 penicillin IV
example_data$route <- ifelse(example_data$route == "PO", "", example_data$route)
example_data
#> antibiotic_type route
#> 1 ciprofloxacin IV
#> 2 ciprofloxacin
#> 3 doxycycline IV
#> 4 doxycycline
#> 5 penicillin IV
#> 6 penicillin IV
#> 7 doxycycline
#> 8 doxycycline
#> 9 penicillin IV
#> 10 penicillin IV
Created on 2023-05-10 by the reprex package (v2.0.1)
system
Closed
May 31, 2023, 3:00pm
5
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.