R on Your iPhone (Not the Way You Think)

[This article was first published on Timely Portfolio, 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.

If you really love R, you should put it on your iPhone.  Apple gives the measurements for its products here. Let’s use a little grid magic with ggplot2 to make a chart for the back of your iphone similar to this.

require(grid)<br />require(ggplot2)<br /><br /># thanks for the Apple measurements<br /># https://developer.apple.com/resources/cases/<br />x11(<br />  height = as.numeric(convertX(unit(58.55, "mm"), "in")),<br />  width = as.numeric(convertX(unit(115.15,"mm"), "in"))<br />)<br /><br /># seems Rstudio make it hard to select a dev use until the new dev is<br /># Active<br />dev.set(which = dev.next())<br /># draw anything to activate our window<br />grid.text("my R iphone case")<br />


# draw your most beautiful plot with ggplot2 or lattice a good example<br /># thanks http://sharpstatistics.co.uk/r/ggplot2-guide/<br />p <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point()<br />p + facet_grid(. ~ Species) + stat_smooth(method = "lm")<br />


# draws rectangular and circular(camera) cutout<br />grid.roundrect(<br />  y = unit(28.975, "mm"),<br />  x = unit(57.275, "mm"),<br />  height = unit(57.95, "mm"),<br />  width = unit(114.55, "mm"),<br />  r = unit(8.17, "mm"),<br />  name = "iphoneback"<br />)<br />grid.circle(<br />  y = unit(49.78, "mm"),<br />  x = unit(106.45, "mm"),<br />  r = unit(3.46, "mm")<br />)<br />


Cut and insert in or paste/tape to your case.


A little more seriously, this is a good way to test how your graph might appear on an iOS device if you have the need.  Just use the screen measurements from the Apple specs.

To leave a comment for the author, please follow the link and comment on their blog: Timely Portfolio.

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.

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)