Ok, thanks to your help, and suggestions.




Manel Amado i Martí
Cap d'Assessoria de Comerç Interior
[email protected]<mailto:[email protected]>
Tel. 93 745 12 63 · Fax 93 745 12 64

[Segueix-nos a Facebook]<https://www.facebook.com/cambrasabadell>  [Segueix-nos 
a Twitter] <https://twitter.com/CambraSabadell>   [Segueix-nos a LinkedIn] 
<http://www.linkedin.com/company/cambra-de-comer-de-sabadell?trk=company_name>
Av. Francesc Macià, 35 · 08206 Sabadell
Apt. corr. 119 · www.cambrasabadell.org<http://www.cambrasabadell.org>




De: Albyn Jones [mailto:[email protected]]
Enviat: dijous, 5 / febrer / 2015 20:46
Per a: Ulises M. Alvarez
A/c: Manel Amado Martí; [email protected]
Tema: Re: [R-sig-teaching] Optimizing loop

Actually, this question should be re-directed to the R-Help list - it is not 
about teaching with R.

albyn

On Thu, Feb 5, 2015 at 9:09 AM, Ulises M. Alvarez 
<[email protected]<mailto:[email protected]>> wrote:
On 02/05/2015 02:08 AM, Manel Amado Martí wrote:
I'm processing a table database. To do that, I put it in a dataframe, and then 
I do the data processing (normalization of some fields). I'm used to program in 
C, and some R's facilities are not so natural to me, please, excuse me if the 
question is for "dummies".
In the processing, I want to substitute some field's value depending on the 
previous content. For example, if field starts with a digit instead of an alpha 
character, the entire field from the actual row, I'll replace it with "SOLPD". 
I'm sure that would be another way (maybe through some apply function), but I 
can't figure how to do.
The code that I'm using now, is:
for( i in 1:nrow(dataframe2)) {
         if(is.na<http://is.na>(dataframe2[i,"NIF/NIE"])==FALSE){
                 
if(str_locate(dataframe2[i,"NIF/NIE"],"\\d<file:///\\d>")[1]<2){
                         sprintf("elimina NIF aut�nom: % i\n",i)
                         dataframe2[i,"NIF"]<-"SLOPD"}
                 }
         }
}

Thank you for your attention!

Hi:

You may take a look at the dplyr library:

https://github.com/hadley/dplyr

If you provide a small, reproducible example, we may provide further help.
--
Ulises M. Alvarez
http://sophie.unam.mx/

_______________________________________________
[email protected]<mailto:[email protected]> mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-teaching


        [[alternative HTML version deleted]]

_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-teaching

Reply via email to