我正在基于邮政编码转换为大型数据集。某些值(中间名和实际名称)可能相似。来自tidyr的传播功能给我一个错误。
zip <- c(02183, 02183, 02184, 02184)
name <- c("Chevregni", "Chevrigny", "Chevresis", "Chevresis")
type <- c("actual_name", "intermediate_name", "actual_name", "intermediate_name")
dummy <- data.frame(zip, name, type)
library(tidyr)
test <- dummy %>% spread(zip, type, name)
预期结果:
zip actual_name intermediate_name
02183 Chevregny Chevresix
02184 Chevresis Chevresis
错误: 行的标识符重复