# NOT RUN {
# a simple vector with only one number per element
StrVal(x=c("week 1", "week 3", "week 4", "week 5"))
# several numbers per element, extract each part, do not paste and return characters
StrVal(x=c("This is 1. place: 45.2", "none", "12.1 but -2.7 follow, 10.2e23 "),
paste = FALSE, as.numeric = FALSE)
# critical are numbers combined with signs, where we sequentially extract valid numbers
StrVal(x=c("78-23-99", "1e-15-34*789+9", "- 34values"),
paste = FALSE, as.numeric = FALSE)
# a typical use case for this function is to reverse a previously
# applied number format
x <- c(100000, 4564654632, -456463)
xf <- Format(x, big.mark="'")
StrVal(xf, paste = TRUE, as.numeric = TRUE)
StrVal(xf, paste = TRUE, as.numeric = FALSE)
StrVal(xf, paste = FALSE, as.numeric = TRUE)
StrVal(xf, paste = FALSE, as.numeric = FALSE)
# use an alternative decimal point
StrVal("8 452,12", dec=",")
# }
Run the code above in your browser using DataLab