在将两个.csv文件合并为公共值后,观察的数量显着减少。我已经确认两个文件具有手动通用值。
这个问题是我以前从未遇到过的,无法弄清为什么会发生。你能帮忙吗?
代码如下:
GII <- read.csv("https://raw.githubusercontent.com/peoplecure/FunTravel/master/Gender%20Inequality%20Index.csv")
eGOV <- read.csv("https://raw.githubusercontent.com/peoplecure/FunTravel/master/EGOV_DATA_2018.csv")
data <- merge(GII, eGOV, by="country")
1 个答案:
答案 0 :(得分:1)
好吧,我想我明白了。我添加了以下选项:header = T,strip.white = T,na.strings = c(“”),stringsAsFactors = FALSE,现在数据包含181个观测值。字符串作为因素被导入,并且因素不匹配。另外,有些国家的空白空间需要清除。
图书馆(dplyr)
GII <-read.csv(“ https://raw.githubusercontent.com/peoplecure/FunTravel/master/Gender%20Inequality%20Index.csv”,标题= T,strip.white = T,na.strings = c(“ “),stringsAsFactors = FALSE)%>%重命名(国家/地区=ï..国家)
eGOV <-read.csv(“ https://raw.githubusercontent.com/peoplecure/FunTravel/master/EGOV_DATA_2018.csv”,标头= T,strip.white = T,na.strings = c(“”),stringsAsFactors =假)
数据<-merge(GII,eGOV,by =“ country”)