You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The spread() verb won't work for data frames if there are duplicates in the keys. It is unfortunate that PIVOT() seems to require an aggregation function, I haven't found a way to write this operation so that no aggregates are performed (but an error is returned instead). Perhaps with a user-defined function?
Either way, FIRST_VALUE() seems to be a slightly better choice than MAX(), because it might also work for non-numeric data.
library(tidyverse)
data<- tibble(a= c(1, 1, 2), b=a, c=4:6)
data %>%
spread(b, c)
#> Error: Duplicate identifiers for rows (1, 2)
The
spread()
verb won't work for data frames if there are duplicates in the keys. It is unfortunate thatPIVOT()
seems to require an aggregation function, I haven't found a way to write this operation so that no aggregates are performed (but an error is returned instead). Perhaps with a user-defined function?Either way,
FIRST_VALUE()
seems to be a slightly better choice thanMAX()
, because it might also work for non-numeric data.The text was updated successfully, but these errors were encountered: