1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 19:01:51 +02:00

(v1.7.1.9004) more extensive unit tests

This commit is contained in:
2021-06-15 10:51:04 +02:00
parent 556bf0014d
commit c44d9392ca
15 changed files with 41 additions and 37 deletions

6
R/mo.R
View File

@ -2048,15 +2048,11 @@ parse_and_convert <- function(x) {
x <- as.data.frame(x, stringsAsFactors = FALSE)[[1]]
}
}
x_class <- class(x)
x <- as.character(x)
x[is.null(x)] <- NA
parsed <- iconv(x, to = "UTF-8")
parsed <- iconv(as.character(x), to = "UTF-8")
parsed[is.na(parsed) & !is.na(x)] <- iconv(x[is.na(parsed) & !is.na(x)], from = "Latin1", to = "ASCII//TRANSLIT")
parsed <- gsub('"', "", parsed, fixed = TRUE)
parsed <- gsub(" +", " ", parsed, perl = TRUE)
parsed <- trimws(parsed)
class(parsed) <- x_class
parsed
}, error = function(e) stop(e$message, call. = FALSE)) # this will also be thrown when running `as.mo(no_existing_object)`
parsed