[R] Correct behavior of Hmisc::capitalize()?
Henrik Bengtsson
hb at biostat.ucsf.edu
Thu Jul 14 23:32:57 CEST 2011
Hi,
from example(capitalize) of the Hmisc package (v 0.8.3) you get:
> capitalize(c("Hello", "bob", "daN"))
[1] "Hello" "Bob" "daN"
Is that "daN" correct?
If so, then this behavior that only *all lowercase strings*, which the
code indicates, will be capitalized is not documented.
> Hmisc::capitalize
function (string)
{
capped <- grep("^[^A-Z]*$", string, perl = TRUE)
substr(string[capped], 1, 1) <- toupper(substr(string[capped],
1, 1))
return(string)
}
<environment: namespace:Hmisc>
There are also some misspelled words in help("capitalize").
> sessionInfo()
R version 2.13.1 Patched (2011-07-09 r56344)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] splines stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] Hmisc_3.8-3 survival_2.36-9
loaded via a namespace (and not attached):
[1] cluster_1.14.0 grid_2.13.1 lattice_0.19-30 tools_2.13.1
/Henrik
(Hmisc maintainer cc:ed)
More information about the R-help
mailing list