Subtracting two columns with conditions

Hi, first off a reproducible example, called a reprex helps quite a bit in attracting responses. Here's what yours should look like:

library(tidyverse)
library(readr)

# cv missing from namespace
cv <- function(x,y){
  x/y
}

url <- "https://github.com/MohJumper/VisualAuditoryModality/raw/master/new_clean_m.csv"
new_clean_m <- read.csv(url)


df_ce <-  new_clean_m %>%
  group_by(stim_ending_t, visbility, soundvolume, Opening_text) %>%
  summarize(m = mean(key_resp_2.rt),
            sd = sd(key_resp_2.rt),
            #ce = (stim_ending_t - m), # stim_ending_t varies, m is constant
                                      # ∴ ce is not an atomic vector
            coefVar = cv(sd,m))

Created on 2019-09-11 by the reprex package (v0.3.0)

While I was composing @FJCC beat me to the mutate part. If you use my cv function,

coefVar = cv(sd,m)) %>% 
2 Likes