R/str_rep_pos_neg.R

Defines functions str_rep_pos_neg str_rep_pos_neg_string str_rep_pos_neg_char

str_rep_pos_neg_char = function( char ){
  if( char == "+" ) return( "p" )
  if( char == "-" ) return( "n" )
  char
}

str_rep_pos_neg_string = function( string ){
  laply( str_split( string, "", simplify = TRUE ), function( char ) str_rep_pos_neg_char( char ) ) %>%
    str_c( collapse = "")
}

#' @export
str_rep_pos_neg = function( string ){
  laply( string, function( x ) str_rep_pos_neg_string( x ) )
}
MiguelRodo/VaccCompData documentation built on Nov. 9, 2023, 10:16 a.m.