# fit a simple linear regression with a binary predictor
mod = lm(charges ~ sex, data = RESI::insurance)
# calculate t-value
t = summary(mod)$coefficients[2, "t value"]
# calculate RESI (S)
S = t2S(t, n = 1338, rdf = 1336)
# determine sample proportions
pi = length(which(RESI::insurance[,"sex"]=="male"))/1338
# convert S to Cohen's d
S2d(S = S, pi = pi)
Run the code above in your browser using DataLab