[R] String manipulation---mixed case

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sun Dec 5 17:18:59 CET 2004


Renaud Lancelot <renaud.lancelot at cirad.fr> writes:

> This question was posted a while ago and answered by Christian
> Hoffmann. I wrapped it in a small function:
> 
> CapLeading <- function (string){
...

Version of same:

s <- "the quick red fox jumps over the lazy brown dog"
ss <- strsplit(s, " ")[[1]]
ss1 <- sub("(.).*", "\\1", ss)
ss2 <- sub(".", "", ss)
paste(toupper(ss1), ss2, sep="", collapse=" ")



-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list