I'm trying to find the row wise max of columns selected using a vector of column names. However, dplyr doesn't seem to accept a vector of names which each have "" around them.
Here's the code I'm using.
ladder.channel <- c("channel_4")
bleed.channels <- c("channel_1", "channel_2", "channel_3", "channel_5")
y <- x %>%
mutate(correction = -pmax(bleed.channels)) %>%
mutate(channel.corr = ladder.channel + correction)
But I get this error:
Error: Problem with `mutate()` column `correction`.
ℹ `correction = -pmax(bleed.channels)`.
x invalid argument to unary operator
Backtrace:
1. `%>%`(...)
8. base::.handleSimpleError(...)
9. dplyr:::h(simpleError(msg, call))
Any idea how to get dplyr to accept a vector to select column names. I've read a few posts, including using all_of
, but can't get it working (How to call column names from an object in dplyr?, Use dynamic variable names in `dplyr`)