[R] subset a string

Simon Blomberg s.blomberg1 at uq.edu.au
Fri Mar 5 06:42:26 CET 2010


substr(x,1,3)

On Thu, 2010-03-04 at 21:32 -0800, Nick Matzke wrote:
> Hi,
> 
> This has got to be easy, but for some reason the simplest things can be 
> the hardest to find help on in R.
> 
> How the heck do I subset a string?
> 
> e.g.,
> 
> x = "abcdef"
> 
> I just want the first 3 characters.
> 
> Cheers!
> Nick
> 
> 
> 

-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson



More information about the R-help mailing list