Googling with R

This snippet is taken from Romain Francois blog.  It shows how to do a  Google site search using R.

http://romainfrancois.blog.free.fr/index.php?category/Snippet

As I mention before, this snippet does a site search using, http://addictedtor.free.fr/graphiques. For better or worse, I’m not sure how yet to make search using only Google. I only spent about 15 minutes playing around with this and didn’t really research how to do this. Anyway, I know you can make a super basic Google query URL by doing something like this:

https://www.google.com/search?q=Hello+World

https://www.google.com/search?q=How+to+code+a+google+search+string

Pretty much all you have to do is type q for query and separate each word with a plus sign. If you’re interested in Google’s search protocol I’ve added a link to their documentation to get you going.


rgg.search <- function( topic, engine = c("Google", "RGG") ){

engine <- match.arg( engine )
url <- URLencode( sprintf( "http://addictedtor.free.fr/graphiques/search.php?q=%s&engine=%s",
topic, engine ) )
browseURL( url )
}

rgg.search( "Andrews plot" )

Additional Resources:

Google’s Search Protocol Reference

http://code.google.com/apis/searchappliance/documentation/46/xml_reference.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s