Email Netiquette
[This article was first published on Apply 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.
A short piece of web-scrapping I sent as a reminder to my colleague.Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count.google.hits <- function(query) { | |
# call Google Search and extract the number of hits | |
url <- paste('http://www.google.com/search?q=', query, sep="") | |
tmp <- readLines(url, warn=FALSE) | |
writeLines(tmp, "c:\\temp\\pokus.html") | |
pattern <- ".*<div id=resultStats>[A-Za-z ]*([0-9 ,]*) results<nobr> \\([0-9.]* seconds\\).*" | |
count.line <- grep(pattern,tmp)[1] | |
hits <- sub(pattern, "\\1", tmp[[count.line]]) | |
hits.as.number <- as.numeric(gsub(",","",hits)) | |
return(hits.as.number) | |
} | |
hours <- seq(from=24, to=6*24, by=24) | |
# hours to be googled | |
results <- rep(0, length(hours)) | |
names(results) <- as.character(hours) | |
for (X in hours) { | |
query <- paste('netiquette', 'recommends', 'to', 'respond', 'to', 'email', | |
'within', paste('"',X,'+hours"', sep=""),sep="+") | |
results[X/24] <- count.google.hits(query) | |
} | |
barplot(results, | |
main="Netiquette recommends to respond to email within X hours", | |
ylab="Number of hits in Google Search", | |
xlab="X", | |
col=rainbow(6) | |
) | |
If you run it the result should be something like…
Datatata!
To leave a comment for the author, please follow the link and comment on their blog: Apply R.
R-bloggers.com 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.