Created
October 25, 2011 15:12
-
-
Save simecek/1313076 to your computer and use it in GitHub Desktop.
Email Netiquette
This file contains hidden or 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) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment