below, when I read in my data.frame using readr::read_csv(), my subsequent code produces NA for yi.
But when I read in my data.frame using Base R's read.csv(), my subsequent code correctly computes yi.
I wonder what's going on?
library(tidyverse)
d <- read_csv("https://raw.githubusercontent.com/fpqq/w/main/n.csv")
d2 <- read.csv("https://raw.githubusercontent.com/fpqq/w/main/n.csv")
d %>% group_by(study) %>% # change `d` to `d2` and compare the results
mutate(n = unlist(mean(c(nT,nC))),
N = nT nC,
w = (nT nC-2)*.8,
icc = .15,
yi = ifelse(assign_type=="group", yi*w, yi)
) %>% ungroup
CodePudding user response:
by default read_csv() converts empty strings to NA.
Try d <- read_csv("https://raw.githubusercontent.com/fpqq/w/main/n.csv", na = c("NA"))
Both data sets should be the same now.
