Re: [S] A casefold() function that caps only the first character

Bill Venables (wvenable@attunga.stats.adelaide.edu.au)
Thu, 17 Sep 1998 07:03:23 +0930


>>>>> "John" == John Wallace <jrw@fish.washington.edu> writes:

John> A function that changes character strings with only the
John> first character in upper case is attached below. [...]

I think John's function suggests the operation is much more
complicated than it need be. Here is a simpler function that
does the same job.

Updown <- function(cv) {
cv <- casefold(cv)
first <- substring(cv, 1, 1)
alpha <- !is.na(match(first, letters))
first[alpha] <- LETTERS[match(first[alpha], letters)]
paste(first, substring(cv, 2), sep="")
}

-- 
_________________________________________________________________
Bill Venables, Head, Dep't of Statistics,   Tel.: +61 8 8303 5418
The University of Adelaide,                 Fax.: +61 8 8303 3696
South AUSTRALIA.     5005.   Email: Bill.Venables@adelaide.edu.au
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news