Generating PPC Keywords in R – Part 2

November 4, 2011

(This article was first published on Abraham Mathew » R, and kindly contributed to R-bloggers)

In a previous post, I discussed how to generate PPC keywords in R. In this post I will provide another example of how to perform this task. Let’s say that I am a auto insurance company that only operates in the state of Illinois. I’m planing on bidding on keywords in Bing and Google which have the name of each city in Illinois followed by ‘auto insurance.’ Using just the sprintf function and a data structure with the Illinois cities, I can generate the desired keywords using the following code. Some of you are probably wondering why an advertiser would bid on keywords that contain each city in Illinois. Well, there are very few instances in which it would make sense to actually bid on keywords that contain city names or zip codes. Just because you can, doesn’t mean you should.

DF <- read.csv("",
               header = FALSE)
DF[ ,c(1,5,6,7,8)] <- NA
df <- DF[,colSums(<nrow(DF)]  #removes all NA values
names(df) <- c("zip", "state", "city")
il = subset(df, state=="IL")
ilcity = unique(tolower(il$city))
ilcity = as.character(ilcity)
ilcity = gsub("(^|[[:space:]])([[:alpha:]])", "\\1\\U\\2", ilcity, perl=TRUE)
dt = c("%s auto insurance")
dat = sprintf(dt, ilcity)

To leave a comment for the author, please follow the link and comment on their blog: Abraham Mathew » R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , ,

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)