Re: [R] substring simultaneous conditions

2016-09-05 Thread ruipbarradas
Hello, Try placing the & immediately after the substr() conditions, like this: base <- baseR[substr(baseR[['ID']],3,4)!='03' & substr(baseR[['ID']],11,12)!='01' & substr(baseR[['ID']],11,12)!='11',] Maybe I'm wrong but R might have decided that

Re: [R] substring simultaneous conditions

2016-09-05 Thread Ulrik Stervbo
Dear Rosa, you can use grep for pattern matching along the lines of: x <- c("00071101", "0007", "00071112","123456789123") grep("^[0-9]{2}07[0-9]{6}(01|11)", x) Here I assume that your real IDs consist of integers only. The pattern matches two integers followed by 07 followed by

[R] substring simultaneous conditions

2016-09-05 Thread Rosa Oliveira
Dear all, I have searched all over and didn“t found an answer :( Sorry, I'm new. I need urgently to "not analyse"the weight the ID's that have 07 in the position 3 and 4 respectively, 01 or 11 in positions 11 and 12 of ID variable. . I used the following code: base<--baseR[substr(baseR$'ID',3,4