Hi, I have a following data frame:
df <- tibble(
Date = (c("01-01-2005", "01-02-2005", "01-04-2005", "01-04-2005")),
item_value = c(5,6,8,1),
item_name = c("a", "b", "b", "a")
)
I would like create a balanced data frame that will look like this:
Date item_value item_name
01-01-2005 5 a
01-01-2005 0 b
01-02-2005 0 a
01-02-2005 6 b
01-03-2005 0 a
.
.
.
I tried this:
df %>% complete(df, nesting(Date, item_name), fill = list(item_value = 0))
but this error occurs:
Error: Column names Date
, item_name
must not be duplicated.
Use .name_repair to specify repair.
How can I fix it please? Thanks a lot!