[R] How do I best create a R procedure from a R file?
Erich Subscriptions
erich.subs at neuwirth.priv.at
Wed Feb 8 19:23:51 CET 2017
Rough sketch:
lookup.vec <- elencositi$nome.sito
names(ookup.vec) <- elencositi$indirezzo.sito
dati$FONTE <- lookup.vec(dati$FONTE)
This, however, assumes that elencositi has all the values that con occur.
> On 8 Feb 2017, at 10:27, Luca Meyer <lucam1968 at gmail.com> wrote:
>
> Hi,
>
> I am working on the following file:
>
>> str(elencositi)
> 'data.frame': 641 obs. of 2 variables:
> $ indirizzo.sito: chr "10ahora.com.ar" "abceconomia.co" "accmag.com" "
> actu.orange.fr" ...
> $ nome.sito : chr "10ahora" "ABC economia" "Acc Magazine" "Orange
> Actu" ...
>
>> head(elencositi)
> indirizzo.sito nome.sito
> 1 10ahora.com.ar 10ahora
> 2 abceconomia.co ABC economia
> 3 accmag.com Acc Magazine
> 4 actu.orange.fr Orange Actu
> 5 affaires.lapresse.ca La Presse
> 6 agipapress.blogspot.it Agigapress
>
> Which is regularly updated and I consequently need to update a procedure
> that takes elencositi data to update dati$FONTE as indicated below:
>
> dati$FONTE <- ifelse(dati$FONTE=='10ahora.com.ar','10ahora',dati$FONTE)
> dati$FONTE <- ifelse(dati$FONTE=='abceconomia.co','ABC economia',dati$FONTE)
> dati$FONTE <- ifelse(dati$FONTE=='accmag.com','Acc Magazine',dati$FONTE)
>
> Currently I am using a time consuming procedure involving Excel to update
> that, but how can I make that automatic?
>
> Thank you in advance,
>
> Luca
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list