Closed jukkiebah closed 3 years ago
Thx! I’ll look into it.
The error was caused because of a syntactic error at your side I'm afraid 🙂
You wrote
df <- df %>% rename_with(df, .fn = as.ab, .cols = amikacine:voriconazol)
But after a pipe, the data object (df
) must be omitted, like this:
df <- df %>% rename_with(.fn = as.ab, .cols = amikacine:voriconazol)
# or even shorter
df <- df %>% rename_with(as.ab, amikacine:voriconazol)
So the error was right, it said that the second argument of as.ab()
(which is flag_multiple_results
) must be TRUE
or FALSE
, not a data set.
So that it worked under 1.4.0 was erroneous, it was incorrectly allowed.
Small idea to make your script independent of variable names (assuming that your variables with AB results are of class <rsi>
, e.g., using as.rsi()
):
df <- df %>%
rename_with(as.ab, where(is.rsi))
If they aren't already of class <rsi>
, you can add this mutate()
:
df <- df %>%
mutate(across(where(is.rsi.eligible), as.rsi)) %>%
# or the good old and way better readable:
# mutate_if(is.rsi.eligible, as.rsi) %>%
rename_with(as.ab, where(is.rsi))
Thanks!! Also for the suggestions. This was a slip-up on my part. It now works perfectly
hai
this code works under AMR 1.4, but not with AMR 1.5:
df <- df %>% rename_with(df, .fn = as.ab, .cols = amikacine:voriconazol)
now with AMR 1.5 I get this error:
Error: in .fn(): argument
flag_multiple_results
must be of class "logical", not "tbl_df/tbl/data.frame"(greetings, Rogier)