Since I do not have your data, I invented a small data set.. The fill() function fills in missing values with the most recent non-missing value so that every row in V1 has a value. The group_by() and Mutate() functions work together to make a new column named ColName that stores the names of the columns that will be made in the next step. You might want to make names that are more informative than V2, V3, etc. The pivot_wider() function pivots the data so there is one row for each value of V1.
library(tidyr)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
DF <- data.frame(V1 = c("A", NA,NA,NA,"B",NA,NA,NA,"C",NA,NA, NA),
V2 = c("AA", "BB", "CC", "DD", "EE", "FF", "GG", "HH", "II", "JJ", "KK", "LL"))
DF
#> V1 V2
#> 1 A AA
#> 2 <NA> BB
#> 3 <NA> CC
#> 4 <NA> DD
#> 5 B EE
#> 6 <NA> FF
#> 7 <NA> GG
#> 8 <NA> HH
#> 9 C II
#> 10 <NA> JJ
#> 11 <NA> KK
#> 12 <NA> LL
DFpivot <- DF %>% fill(V1) %>%
group_by(V1) %>%
mutate(ColName = paste0("V",row_number() + 1)) %>%
pivot_wider(names_from = ColName, values_from = V2)
DFpivot
#> # A tibble: 3 x 5
#> # Groups: V1 [3]
#> V1 V2 V3 V4 V5
#> <chr> <chr> <chr> <chr> <chr>
#> 1 A AA BB CC DD
#> 2 B EE FF GG HH
#> 3 C II JJ KK LL
Created on 2021-04-30 by the reprex package (v0.3.0)