This would be a minimal example of code that raises this error.
library(dplyr)
library(tidyr)
wide <- data_frame(
number = c(1:3, 1:3),
value = letters[1:6])
wide
#> # A tibble: 6 x 2
#> number value
#> <int> <chr>
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 1 d
#> 5 2 e
#> 6 3 f
long <- wide %>%
gather(variable, value, -number)
long
#> # A tibble: 6 x 3
#> number variable value
#> <int> <chr> <chr>
#> 1 1 value a
#> 2 2 value b
#> 3 3 value c
#> 4 1 value d
#> 5 2 value e
#> 6 3 value f
long %>%
spread(variable, value)
#> Error: Duplicate identifiers for rows (1, 4), (2, 5), (3, 6)
One way to think about the problem is that there is more than one way to spread the data when there are repeated identifiers. For example, which of these is correct?
#> # A tibble: 6 x 2
#> number value
#> <int> <chr>
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 1 d
#> 5 2 e
#> 6 3 f
#> # A tibble: 6 x 2
#> number value
#> <int> <chr>
#> 1 1 d
#> 2 2 e
#> 3 3 f
#> 4 1 a
#> 5 2 b
#> 6 3 c
I'm not sure if this is the exact reason why rows must be uniquely identifiable, but it makes sense. tidyr is a little stricter in some ways than reshape2.
Fortunately, we can make rows uniquely identifiable by just numbering them with something like tibble::rowid_to_column().
long <- wide %>%
tibble::rowid_to_column() %>%
gather(variable, value, -number, -rowid)
long %>%
spread(variable, value)