[R] Left/right hand side characters

J.delasHeras at ed.ac.uk J.delasHeras at ed.ac.uk
Mon May 14 19:11:58 CEST 2007


check ?substr

> substr("item54",1,5)
[1] "item5"

Jose


Quoting "Brooks, Anthony B" <anthony.brooks at csc.mrc.ac.uk>:

> Hello all
>
> Is there a way reducing the number of characters in a list so that just
> the left n numbers of characters is given?
>
> For example, If I have a list, listnames, which consists of 4 strings of
> 6 characters;
>
>
>
>> listnames
>
> [1] "item12" "item34" "item56" "item78"
>
>
>
> Is there a way to reduce this so only the 5 characters on the lefthand
> side are given (similar to the LEFT function in Excel)
>
>
>
> So that I'd get a list like this
>
>
>
>> listnames
>
> [1] "item1" "item3" "item5" "item7"
>
>
>
> Thanks
>
> Tony
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
>



-- 
Dr. Jose I. de las Heras                      Email: J.delasHeras at ed.ac.uk
The Wellcome Trust Centre for Cell Biology    Phone: +44 (0)131 6513374
Institute for Cell & Molecular Biology        Fax:   +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK



More information about the R-help mailing list