R中的公共值合并

R中的公共值合并,r,csv,R,Csv,通过公共值合并两个.csv文件后,观察次数显著减少。我已手动确认两个文件具有相同的值 这个问题是我以前从未遇到过的,我无法理解为什么会发生这种情况。你能帮忙吗 代码如下: GII <- read.csv("https://raw.githubusercontent.com/peoplecure/FunTravel/master/Gender%20Inequality%20Index.csv") eGOV <- read.csv("https://raw.githubuserconte

通过公共值合并两个.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")

好的,我想我明白了。我添加了以下选项:header=T,strip.white=T,na.strings=c,stringsAsFactors=FALSE,现在数据包含181个观察值。字符串正在作为因子导入,但因子不匹配。此外,还有一些国家需要清除这些游离的空白

library(dplyr)
GII <- read.csv("https://raw.githubusercontent.com/peoplecure/FunTravel/master/Gender%20Inequality%20Index.csv", header = T, strip.white = T, na.strings = c(""), stringsAsFactors = FALSE) %>% rename(country = ï..country)
eGOV <- read.csv("https://raw.githubusercontent.com/peoplecure/FunTravel/master/EGOV_DATA_2018.csv", header = T, strip.white = T, na.strings = c(""), stringsAsFactors = FALSE)
data <- merge(GII, eGOV, by="country")

谢谢我唯一的建议是为管道添加库,我必须更改重命名country=ï..country。除此之外,它工作得非常好!