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
janek0 wrote:>Dnia 25-04-2007, ?ro o godzinie 15:04 +0200, Abi Ghanem josephine >napisa?(a): > >use "data[grep("^24|N7", data$V2)]" >and see ?regexp > >thanks for replying but actually my problem is that the column containing 23 is in data$V2 and the one containing N7 is in data$V3, so the line doen't work i just have all the line containing G23 N7 and G23 O6 and i want to separate the two. josephine
On 25/04/07, Abi Ghanem josephine <josephine.abighanem@ibpc.fr> wrote:> > 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 workhow about data[ intersect( grep("^24", data$V2), grep("N7",data$V3) ) , ] ? C. [[alternative HTML version deleted]]