urlshorteneR: A package for shortening URLs

September 14, 2015

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

This is a small package I put together quickly to satisfy an immediate need: generating abbreviated URLs in R. As it happens I require this functionality in a couple of projects, so it made sense to have a package to handle the details. It’s not perfect but it does the job. The code is available from github along with vague usage information.

In essence the functionality is simple: first authenticate to shortening service (goo.gl and bitly are supported at present) then shorten or expand URLs as required. The longurl package will perform the latter function too, possibly with greater efficiency.

So, for example, with goo.gl:

> shorten.google("http://www.google.com")
[1] "http://goo.gl/MYyLu2"
> expand.google("http://goo.gl/MYyLu2")
[1] "http://www.google.com/"

And then doing the same thing with bitly:

> shortener_authenticate("692987373e98473p3fbed10e7c2ea15d6c56fd82",
                         "945d4fe36d8596zap73421090260pfp0d7cbc1a9", "bitly")
> shorten.bitly("http://www.google.com")
[1] "http://bit.ly/1Qho4Y5"
> expand.bitly("http://bit.ly/1Qho4Y5")
[1] "http://www.google.com/"

The post urlshorteneR: A package for shortening URLs appeared first on Exegetic Analytics.

To leave a comment for the author, please follow the link and comment on their blog: Exegetic Analytics » R.

R-bloggers.com 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...

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)