In the past, I created a label in a new column like
df$type[df$variable %in% c("sw.1.", "sw.2.", "sw.3.", "sw.4.", "sw.5.")]<-"water"
df$type[df$variable %in% c("st.1.", "st.2.", "st.3.", "st.4.", "st.5.")]<-"temp"
but now I am using dplyr and would like to pipe it in. However, I can't figure out how to do this with mutate. Here is my first shot:
mutate(df, type = ((select(df, starts_with("sw"))) == "temp"))
but it doesn't work.
Some example data:
plot variable value
3 sw1 4
4 sw1 5
3 sw1 4
4 sw2 2
5 sw2 3
3 st1 4
4 st2 5
5 st1 5
4 st2 2