[R] grep
1Rnwb
sbpurohit at gmail.com
Wed Oct 20 21:01:52 CEST 2010
Hi
I have a script which is designed to gather data from individual columns
from a file, which is an output from an instrument. the file has multiple
sections and each a section has data under each column (vars), I am using
the name of the column as a variable to gather the column ID using
vidx<-grep(vars[vi],gsub("[[:punct:]]","",strrl1[[datbeg-1]]),ignore.case=T)
the vidx stores the column ID for each 'vars', which in subsequent step is
stored in a temp vector for analysis
strrl1[[datbeg-1]] is the position in the file where the data begins( the
data is given below)
This is working fine when i have all the unique names for 'vars' the trouble
started when I started working with files having column names starting with
exactly same alphabets for eg, Apo AII and Apo AI the vidx returns multiple
column ids and in the following example it 'vidx' returns 3 and 5
Location Sample Apo AII Apo B Apo AI Apo CII Apo CIII Apo E Total Events
1(1,A1) PC1 32310 5947 55069 21856 66539 54589 321
2(1,B1) PC2 33772 2754 50452.5 20588 68813 45586 268
3(1,C1) PC3 25386 960 38045 12992 57239 28939.5 275
4(1,D1) PC4 23604 475 40056 14433 59969.5 19788 275
5(1,E1) PC5 13469 216 31967 8900 55937 13534 257
6(1,F1) PC6 11142.5 174.5 30025 9465 64848 11053 244
7(1,G1) PC7 1021 129.5 11405 3661 50841 2466 236
8(1,H1) S1 29339 7721.5 55777 14939 50864 11369 252
9(1,I1) S2 17315.5 2485 40010 10756.5 45471.5 5133 239
10(1,J1) S3 18440 1406 47276.5 15425 44740 2815.5 264
11(1,K1) S4 19011 756 55982.5 12801 38148 1265 273
12(1,L1) S5 6372 278 28585 5210 10605 664 259
13(1,M1) S6 2608 223 13819 2559 3143 274 260
14(1,N1) S7 408.5 198 3775 834 443 117.5 252
15(1,O1) S8 114.5 135 860 538 135 73.5 242
Thanks
Sharad
--
View this message in context: http://r.789695.n4.nabble.com/grep-tp3004422p3004422.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list