按公用值合并两个.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")发布于 2018-12-13 10:02:22
好了,我想我明白了。我添加了这些选项:header = T, strip.white = T, na.strings = c(""), stringsAsFactors = FALSE,现在data包含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")https://stackoverflow.com/questions/53753919
复制相似问题