Re: [R] lower/upper case question

2010-12-20 Thread Bos, Roger
toupper() and tolower() 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Erin Hodgess
Sent: Friday, December 17, 2010 4:10 PM
To: R help
Subject: [R] lower/upper case question

Dear R People:

Is there a function to convert a character string to all uppercase or
all lowercase please?

I'm sure that I've used one before but I'm drawing a blank.

Thanks,
Erin


--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences University of Houston -
Downtown
mailto: erinm.hodg...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
***

This message is for the named person's use only. It may\...{{dropped:20}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] lower/upper case question

2010-12-17 Thread Erin Hodgess
Dear R People:

Is there a function to convert a character string to all uppercase or
all lowercase please?

I'm sure that I've used one before but I'm drawing a blank.

Thanks,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lower/upper case question

2010-12-17 Thread Greg Snow
See ?toupper for the toupper, tolower, chartr, and casefold functions.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Erin Hodgess
 Sent: Friday, December 17, 2010 2:10 PM
 To: R help
 Subject: [R] lower/upper case question
 
 Dear R People:
 
 Is there a function to convert a character string to all uppercase or
 all lowercase please?
 
 I'm sure that I've used one before but I'm drawing a blank.
 
 Thanks,
 Erin
 
 
 --
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: erinm.hodg...@gmail.com
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lower/upper case question

2010-12-17 Thread William Dunlap
Also, gsub() can change the case of part a string --
use perl=TRUE and \\U or \\L (and perhaps \\E) in
the replacement string.  E.g., capitalize color names
with
   gsub(paste(sep=, (, paste(colors(),collapse=|), )),
\\U\\1,
The quick red Fox jumped over the lazy brown Dog,
perl=TRUE)
  [1] The quick RED Fox jumped over the lazy BROWN Dog

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Greg Snow
 Sent: Friday, December 17, 2010 1:19 PM
 To: Erin Hodgess; R help
 Subject: Re: [R] lower/upper case question
 
 See ?toupper for the toupper, tolower, chartr, and casefold functions.
 
 -- 
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 greg.s...@imail.org
 801.408.8111
 
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
  project.org] On Behalf Of Erin Hodgess
  Sent: Friday, December 17, 2010 2:10 PM
  To: R help
  Subject: [R] lower/upper case question
  
  Dear R People:
  
  Is there a function to convert a character string to all 
 uppercase or
  all lowercase please?
  
  I'm sure that I've used one before but I'm drawing a blank.
  
  Thanks,
  Erin
  
  
  --
  Erin Hodgess
  Associate Professor
  Department of Computer and Mathematical Sciences
  University of Houston - Downtown
  mailto: erinm.hodg...@gmail.com
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
  guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lower/upper case question

2010-12-17 Thread Gabor Grothendieck
On Fri, Dec 17, 2010 at 4:38 PM, William Dunlap wdun...@tibco.com wrote:
 Also, gsub() can change the case of part a string --
 use perl=TRUE and \\U or \\L (and perhaps \\E) in
 the replacement string.  E.g., capitalize color names
 with
   gsub(paste(sep=, (, paste(colors(),collapse=|), )),
    \\U\\1,
    The quick red Fox jumped over the lazy brown Dog,
    perl=TRUE)
  [1] The quick RED Fox jumped over the lazy BROWN Dog


Nice example. Here are two ways to do it with gsubfn:

library(gsubfn)
phrase - The quick red Fox jumped over the lazy brown Dog

# 1
gsubfn(\\w+, ~ if (tolower(x) %in% colors()) toupper(x) else x, phrase)

# 2
# Colors is a list with lower case values and upper case names
# Unlike the last one this will not capitalize mixed case, only lower

Colors - as.list(setNames(toupper(colors()), colors()))
gsubfn(\\w+, Colors, phrase)



-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.