I have the following data frame that looks like this (3 columns as list).
A tibble: 14 x 4
clinic_name drop_
exploratory::list_to_text()
will convert a list
column to a character
column. The default is sep = ", "
, which I recommend changing to something else if writing to a .csv.
devtools::install_github("exploratory-io/exploratory_func")
list_to_text <- function(column, sep = ", "){
loadNamespace("stringr")
ret <- sapply(column, function(x) {
ret <- stringr::str_c(x, collapse = sep)
if(identical(ret, character(0))){
# if it's character(0)
NA
} else {
ret
}
})
as.character(ret)
}
https://github.com/exploratory-io/exploratory_func/blob/master/LICENSE.md