Help with Collapsing and Reshaping Data Frame

Is this what you mean?

library(dplyr)

DrugDose <- data.frame(
  stringsAsFactors = FALSE,
      transplantid = c(768865,768865,768865,768865,
                       768865,768865,768865,768865,768865,768865,768865,
                       768865,1033869,1033869,1033869,1033869,1033869,
                       1033869,1033869,1033869,1033869,1033869,1033869,1033869,
                       1033869,1033869,1033869,1033869,1033869,1033869),
          drugcode = c("P","V","X","P","V","X",
                       "P","V","X","P","V","X","E","P","V","E","P","V",
                       "E","P","V","E","P","V","E","P","V","E","H",
                       "P"),
         monthcode = c("Initial","Initial","Initial",
                       "3 Mth","3 Mth","3 Mth","1 Yr","1 Yr","1 Yr",
                       "2 Yr","2 Yr","2 Yr","Initial","Initial","Initial",
                       "3 Mth","3 Mth","3 Mth","1 Yr","1 Yr","1 Yr","2 Yr",
                       "2 Yr","2 Yr","3 Yr","3 Yr","3 Yr","7 Yr","7 Yr",
                       "7 Yr")
)

DrugDose %>% 
    group_by(transplantid) %>%
    filter(monthcode == first(monthcode)) %>% 
    summarise(drugcode = paste0(drugcode, collapse = ""),
              monthcode = first(monthcode))
#> `summarise()` ungrouping output (override with `.groups` argument)
#> # A tibble: 2 x 3
#>   transplantid drugcode monthcode
#>          <dbl> <chr>    <chr>    
#> 1       768865 PVX      Initial  
#> 2      1033869 EPV      Initial

Created on 2020-11-24 by the reprex package (v0.3.0.9001)

Note: Next time please provide a proper REPRoducible EXample (reprex) illustrating your issue.