Skip to content
Back to formatted view

Raw Message

Message-ID: <9388BA7C-E4BA-4B6D-AF4A-E457F0009CBB@neuwirth.priv.at>
Date: 2017-02-08T18:23:51Z
From: Erich Subscriptions
Subject: How do I best create a R procedure from a R file?
In-Reply-To: <CABQyo84onPdGV-Kyb8mNKZodY8meb4GsCNveE0eckNMS6G6ZCA@mail.gmail.com>

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.