下面,當我使用 讀取我的 data.frame 時readr::read_csv(),我的后續代碼NA為yi.
但是當我使用 Base R's 在我的 data.frame 中讀取時read.csv(),我的后續代碼正確地計算了yi.
我想知道這是怎么回事?
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
uj5u.com熱心網友回復:
默認情況下read_csv()將空字串轉換為NA.
嘗試 d <- read_csv("https://raw.githubusercontent.com/fpqq/w/main/n.csv", na = c("NA"))
兩個資料集現在應該是相同的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/377752.html
