[R] assigning two conditions to grep()

Abi Ghanem josephine josephine.abighanem at ibpc.fr
Wed Apr 25 15:04:35 CEST 2007


Hi,
i have a problem in assigning 2 conditions to grep()  ,
my data look like this:
DA 24 N7 Rad= 3.4 20 Sac= 0.93 Acc= 4.76
DA 24 N7 Rad= 3.4 14 Sac= 0.65 Acc= 3.33
DA 24 N7 Rad= 3.4  3 Sac= 0.14 Acc= 0.71
DA 24 N7 Rad= 3.4 11 Sac= 0.51 Acc= 2.62
DG 23 N7 Rad= 3.4  8 Sac= 0.37 Acc= 1.91
DG 23 N7 Rad= 3.4  5 Sac= 0.23 Acc= 1.19
DG 23 N7 Rad= 3.4  0 Sac= 0.00 Acc= 0.00
DG 23 N7 Rad= 3.4  3 Sac= 0.14 Acc= 0.71
DG 23 O6 Rad= 3.3  0 Sac= 0.00 Acc=  0.00
DG 23 O6 Rad= 3.3  1 Sac= 0.04 Acc=  0.22
DG 23 O6 Rad= 3.3  0 Sac= 0.00 Acc=  0.00
DG 23 O6 Rad= 3.3  0 Sac= 0.00 Acc=  0.00
(it's a data.frame)

at first i wanted all the line begining with A 24:
data[grep("^24", data$V2)]
this works
and than i wanted to exctract all the lines with G23 N7,
neither the column 23 and the column N7 are unique
so i tried this
 data[grep("^23*N7", data),]
but doesn't work
not either
x[(grep("^N7", as.character(x$V3))) &(grep("^23", x$V2)),]
he just returns everything.

thank u for any help,
josephine



More information about the R-help mailing list