Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

convert_var_to_ascii() in R/utils.R twice #31

Closed
sarabodach opened this issue Feb 24, 2023 · 0 comments · Fixed by #32
Closed

convert_var_to_ascii() in R/utils.R twice #31

sarabodach opened this issue Feb 24, 2023 · 0 comments · Fixed by #32

Comments

@sarabodach
Copy link
Collaborator

sdtmchecks/R/utils.R

Lines 330 to 363 in a4ebf93

#' Remove non-ASCII characters from reported term in order
#' for Pandoc to create PDF file
#'
#'
#' @param df dataframe
#' @param var variable with non-ASCII characters
#'
#' @return dataframe
#' @export
#' @keywords internal
#'
#' @examples
#'
#' df <- data.frame(
#' var = c("test", "teäst"),
#' stringsAsFactors = FALSE
#' )
#'
#' df <- convert_var_to_ascii(df, 'var')
#'
#' df <- data.frame(
#' usubjid = 1:2,
#' var = c("test", "teästõ"),
#' stringsAsFactors = FALSE
#' )
#'
#' df <- convert_var_to_ascii(df, 'var')
convert_var_to_ascii <- function(df, var){
Encoding(df[[var]]) <- "latin1"
df[[var]] <- iconv(df[[var]], "latin1", "ASCII", sub="")
return(df)
}

-Function code is the same
-Only minor difference in the examples shown in the header:
Line 253, 261: convert_var_to_ascii(df, 'var')
Line 348, 356: df <- convert_var_to_ascii(df, 'var')

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant