mutate from rowwise

Asked 2 years ago, Updated 2 years ago, 109 views

I'm trying to mutate from rawwise with dplyr, but it doesn't work.

·Executing the code below will result in an error.

df%>%rowwise()%>%mute(row_max=max(starts_with("X"))))
Error: Notidyselect variables were registered

·Therefore, avoid it

col%>%rowwise()%>%mute(row_max=max(X1:X17))

Then, the largest value does not get stuck.
It contains values like 1.90e-3 and 7.54e-3, so is it not accurate?
(1.90e-3 and 7.54e-3 are on the same line, but 1.90e-3 seems to be selected as max.
1.90e-3<7.54e-3 says True.)

If you are familiar with this, please take care of me.

r tidyverse dplyr

2022-09-30 19:33

1 Answers

I think you should use purrr::pmap().

 mutate maximum starting with "Sepal" in #iris data
iris%>%mute(max=select(.,starts_with('Sepal'))%>%pmap(.,~max(.))))


2022-09-30 19:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.