I have a long dateset like this sample data
df <- tibble::tribble(
~V1, ~V2, ~V3,
1L, "Hig", 3131000L,
2L, "Hig", 279000L,
3L, "Hig", 1316000L,
1L, "val", 1882000L,
2L, "val", 1433000L,
3L, "val", 555000L,
4L, "val", 856000L,
1L, "nt", 4493000L,
2L, "nt", 233000L,
3L, "nt", 693000L
)
I want to change this to the wide format without taking into account the V1 variable and cols names. Desired output should be like this (exported as a txt file)
High,3131000,279000,1316000,
val,1882000,1433000,555000,856000,
nt,4493000,233000,693000,
I simply tried this
df %>%
select(V2, V3) %>%
pivot_wider("V2", values_from="V3" )
Error: Column 1 must be named.
Use .name_repair to specify repair.