Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Camelcase
camelCase = function(sv, upper=FALSE, capIsNew=FALSE, alreadyTrimmed=FALSE) { if (!is.character(sv)) stop("'sv' must be a string vector") if (!alreadyTrimmed) sv = gsub("[[:space:]]*$", "", gsub("^[[:space:]]*", "", sv)) if (capIsNew) { sv = gsub("([A-Z])", " \\1", sv) sv = gsub("^[[:space:]]", "", sv) sv = tolower(sv) } apart = strsplit(sv, split="[[:space:][:punct:]]") apart = lapply(apart, tolower) capitalize = function(x) paste0(toupper(substring(x,1,1)), substring(x,2)) if (upper) { apart = lapply(apart, capitalize) } else { apart = lapply(apart, function(x) c(x[1], capitalize(x[-1]))) } return(sapply(apart, paste, collapse="")) } # Optional testing if (exists("testingCamelCase")) { vec = c("Oh, Here I am, John", "Oh, that_is_OK, John", "Oh, fine, John") print(camelCase(vec)) if (!exists("dropSame")) source("dropFrontSame.R") print(camelCase(dropSame(vec))) print(camelCase(dropSame(vec), upper=TRUE)) vec2 = c("OhHereIAm", "ThatIsOK", "fine_with-me") print(camelCase(vec2)) print(camelCase(vec2, capIsNew=TRUE)) vec3 = c(" all_three", " two-to-1 ", "terminal ", "termi inal ") print(camelCase(vec3)) print(camelCase(vec3, alreadyTrimmed=TRUE)) }
run
|
edit
|
history
|
help
0
19-08-2020-JacobiSistema
SampleDiscrFR.r
Generate numbers based on mean and stdev
14-09-2020GRam
Análise de Variâncias DIC e teste de Tukey
Predictive power of a test when False positive rate = False negative rate
dataset1
Análise de Variâncias DIC e teste de Tukey 1
Chapter 4:Comparing Distributions (same scale)
AjusteNaoLinear11-02-21