My data looks like this:
item | range |
---|---|
Item01 | Range 1 |
Item02 | Range 2 |
Item03 | Range 2 |
Item04 | Range 2 |
Item05 | Range 1 |
I am trying to use the pivot_wider function to expand out the data based on the range column. I use the following code
dt %>%
pivot_wider(names_from = range, values_from = item)
Which gives me the following warning message:
Warning message:
Values are not uniquely identified; output will contain list-cols.
* Use `values_fn = list` to suppress this warning.
* Use `values_fn = length` to identify where the duplicates arise
* Use `values_fn = {summary_fun}` to summarise duplicates
I am looking for output like this:
Range 1 | Range 2 |
---|---|
Item01 | Item02 |
Item05 | Item03 |
Item04 |
Any suggestions on how to pivot_wider and overcome this issue? Thanks.