How to calculate an effect size for chi-square in R For the life of me I cannot figure out how to do something that should be so simple. I have found http://www.real-statistics.com/chi-square-and-f-distributions/effect-size-chi-square/ but it gives no reason why I should use Cramer's V over say Cohen's W. And for the life of me I cannot find a simple r code that does this.
I've tried creating my own script, but it doesn't seem to give correct answers
Cramers_V <- function(chi, n, df) sqrt((chi)/(n * df))

My data is 2 columns, 4 rows.
 A: Your function looks fine. Just remember the degrees of freedom here is in fact $min(\text{Cols}-1, \text{ Rows}-1)$, so your df will be $2 - 1 = 1$. Both the "lsr" and "rcompanion" packages also have functions to calculate Cramer's V. The latter is particularly nice as it gives bootstrap estimated confidence intervals for the V statistic.
Reproducible example:
# Agresti(2007) p.39 - Taken from ?chisq.text documentation
M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(M) <- list(gender = c("F", "M"), party = c("Democrat","Independent", "Republican"))

# Calculate the chi-square
Xsq <- chisq.test(M)

# Custom function
Cramers_V <- function(chi, n, df) sqrt((chi)/(n * df))

# Find degrees of freedom - min row or col - 1
df <- min(dim(M)) - 1

# Calculate
Cramers_V(chi = Xsq$statistic, n = sum(M), df = df)

# Result = 0.1044358
# Agrees with both:
# lsr::cramersV(M)
# rcompanion::cramerV(M, ci = TRUE)

There doesn't appear to be any definitive answer as to whether Cohen's W or Cramer's V is preferable. Both reduce to a $\phi$ correlation coefficient in the case of a 2x2 table. 
V is more familiar to researchers and bounded by 0 and 1 which is nice. On the other hand, the magnitude or 'strength' of V depends on the degrees of freedom, so a V = .3 when df = 1 is not the same as V = .3 when df = 4. W doesn't appear to have this problem, and can be used to determine power for further studies following Cohen (1988), but it is not bounded by 1 (although it's rare W exceeds 1).

References
Cohen, J. (1988). Statistical power analysis for the behavioral sciences. Routledge.
