[R] Extract elements that starts with...

Ivan Calandra ivan.calandra at uni-hamburg.de
Wed Nov 17 10:58:13 CET 2010


Hi,

A reproducible example would have been nice...

Here is one:
vect <- c(rep("| A010 |",3), rep("| A020 |",5), rep("| A021 |",2))
df <- data.frame(a=vect, b=rnorm(10), d=rnorm(10))
df[grep(pattern="A02", df$a), ]

HTH,
Ivan

Le 11/17/2010 10:16, Joel a écrit :
> Hi
>
> I got an table that contains this colum and i wonder if there is any nice
> way to extract all rows that contains all dose that start with A02, so all
> the rows that have A020 and A021 etc etc...
>
> | A010 |
> | A010 |
> | A010 |
> | A020 |
> | A020 |
> | A020 |
> | A020 |
> | A020 |
> | A021 |
> | A021 |
>
>
> Thx for your help
> //Joel

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php



More information about the R-help mailing list