[R] substring simultaneous conditions

Rosa Oliveira rosita21 at gmail.com
Mon Sep 5 13:51:33 CEST 2016


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)!='03'
                      &substr(baseR$'ID',11,12)!='01'
                       &substr(baseR$'ID',11,12)!='11',]

But, instead of removing just the id's that respect the 3 conditions
simultaneously, base don't have all the id's that have 03 in the 3 and 4
positions os id variable, neither 01  in positions 11 and 12 of ID, neither 11
in positions 11 and 12 of ID variable.variable.

So, it seems, that the code exclude all the conditions, as it was a OR (|)
condition in spite of AND (&) condition.

Can anyone help me please?

I attach the data.

Best,
Rosa Oliveira

__________________________________

Antes de imprimir este e-mail pense bem se tem mesmo que o fazer.
Há cada vez menos árvores.
Não imprima, pense na sua responsabilidade e compromisso com o MEIO
AMBIENTE!
<http://pt.dreamstime.com/cora-ccedil-atildeo-criado-das-folhas-de-aacutervores-diferentes-thumb12275776.jpg>
<http://pt.dreamstime.com/cora-ccedil-atildeo-criado-das-folhas-de-aacutervores-diferentes-thumb12275776.jpg>


More information about the R-help mailing list