format_presence.R 591 Bytes
Newer Older
Grelot Frederic's avatar
Grelot Frederic committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#' @title Transform ods table presence in md table (for Mattermost)
#'
#' @param x character or data.frame, path of the ods table or the table itself
#'
#' @return character, md version of table behind x.
#' 
#' @export
#'
#' @encoding UTF-8
#' @author Frédéric Grelot
 
format_presence = function(x) {
    result = if (is.character(x)) readODS::read_ods(x[1]) else x
    result[]  = lapply(result, gsub, pattern = "B", replacement = "**B**")
    result[]  = lapply(result, gsub, pattern = "C", replacement = "*C*")
    knitr::kable(result, align = c("l", rep("c", length(result) - 1)))
}