Two pending features to metricsgraphics

July 5, 2015

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

I’ve been slowly prodding the metricsgraphics package towards a 1.0.0 release, but there are some rough edges that still need sorting out. One of them is the ability to handle passing in variables for the x & y accessor values (you can pass in bare and quoted strings). This can now be achieved (in the dev01 branch) via mjs_plot_ and in mjs_plot proper in the github main branch thanks to a PR by Jonathan Owen. If everything stays stable with the PR, I’ll just fold the code into mjs_plot for the 0.9.0 CRAN release.

One other pending feature is the ability to turn basic (single geom_) ggplot objects into metricsgraphics plots. Sometimes it’s just easier/nicer to “think” in ggplot and it may be the case that one might have coded a quick histogram/scatter/line plot in ggplot and want an equally quick interactive version. This can also now be achieved (again, in beta) via as_mjsplot. While the previous addition is fairly self-explanatory, this new one needs a few examples. Please note that the package installation is coming from the dev01 branch:

devtools::install_github("hrbrmstr/metricsgraphics", ref="dev01") 
dat <- data.frame(year=seq(1790, 1970, 10),
movies <- movies[sample(nrow(movies), 1000), ]
gg1 <- ggplot(dat, aes(x=year, y=uspop)) + geom_line()
gg2 <- ggplot(dat, aes(x=year, y=uspop)) + geom_point()
gg3 <- ggplot(movies, aes(rating)) + geom_histogram()
gg4 <- ggplot(movies, aes(rating)) + geom_histogram(binwidth = 0.1)

Which you can see below:

As you can see, as_mjsplot will do it’s best to figure out the bins (if using geom_histogram) and also axis labels. Support for converting geom_vline and geom_hline to markers and baselines (respectively) is a work in progress.

I’ve only done limited testing with some basic single geom_ constructs, but if there are any bugs with it or feature requests (remember, the MetricsGraphics.js library has a very limited repertoire) please post an issue on GitHub tagging the dev01 branch.

To leave a comment for the author, please follow the link and comment on their blog: » R. 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.

Search R-bloggers


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)