Hi bro next time please submit a reproducible example.
Try this:
tibble(col = c('a1','a1','a2','a2','a2', 'a3','a3'),
val = c(1,2,1,2,3,1,2)) %>%
group_by(col) %>%
mutate(rank = row_number()) %>%
ungroup() %>%
spread(key = rank, value = val) %>%
mutate_all(., ~replace_na(.x, 0)) %>%
rename('one' =`1`,'two' = `2` , 'three' = `3`)
# A tibble: 3 x 4
col one two three
<chr> <dbl> <dbl> <dbl>
1 a1 1 2 0
2 a2 1 2 3
3 a3 1 2 0