Collapse comments coercing each element to a string (character scalar) and then collapsing into a single string using the '. ' separator.
Examples
collapse_comments("Saw fish", character(0), "Nice. .", NA_character_)
#> [1] "Saw fish. Nice."
data <- data.frame(
visit = c(1, 1, 2, 2),
fish = 1:4,
comment = c("Sunny day. ", "Skinny fish", "Lost boot", NA)
)
if (FALSE) { # \dontrun{
data |>
dplyr::group_by(visit) |>
dplyr::summarise(comment = collapse_comments(comment)) |>
dplyr::ungroup()
} # }