1

I am converting long to large dataset based on zip code. Some values (intermediate and actual names) can be similar. Spread function from tidyr returns me an error.

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)

Expected result :

zip     actual_name      intermediate_name  
02183   Chevregny        Chevresix
02184   Chevresis       Chevresis

Error : Duplicate identifiers for rows

Wilcar
  • 2,119
  • 1
  • 19
  • 42

0 Answers0