Generating PPC Keywords in R – Part 2

[This article was first published on Abraham Mathew » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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)