[R] grep

Chuck Cleland ccleland at optonline.net
Fri Mar 12 19:57:47 CET 2004


Ernesto Jardim wrote:
> I want to use the first digit of the elements of a vector.
> 
> I've tried grep but didn't work.
> 
> Any help is welcome.

substr(as.character(runif(100,0,2)), 1, 1)

see ?substr

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list