[R] Extract elements that starts with...

Ivan Calandra
Wed, 17 Nov 2010 09:58:13 -0000

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

**********