1 |
x |
|
tofactor |
|
stop |
|
blanks |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, tofactor = is.factor(x), stop = c(" The", " Of",
" By", " To", " And"), blanks = c(" ", "(", "\"", "/", "+"))
{
under2blank <- T
if (is.factor(x)) {
ret <- cap1(levels(x))
if (length(unique(ret)) != length(ret))
warning("factor levels have been shortened")
levels(x) <- ret
return(x)
}
ret <- as.character(x)
for (ii in 1:length(ret)) {
z <- ret[[ii]]
if (under2blank)
z <- gsub("_", " ", z)
n <- nchar(z)
z <- substring(z, 1:n, 1:n)
zu <- toupper(z)
zl <- tolower(z)
zb <- c(" ", zu[-n])
z <- paste(ifelse(zb %in% blanks, zu, zl), collapse = "")
for (ss in stop) z <- gsub(ss, tolower(ss), z)
ret[[ii]] <- z
}
ret
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.