Site icon R-bloggers

R pkg Easter Eggs — Revenge of Pacman!

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

In my last post, I praised the virtues of pacman. I also wanted to indulge of one of the main benefits of working with one of pacman’s devs: Tyler Rinker.

Tyler is a geek’s geek, in the best possible way. And one of the best officemates one could ask for to boot! As evidence of that, I thought I’d share a bit of the R-dev goodness that Tyler infused into his pacman package. The fun is a sign of the quality.

Test out this bit of code to find one of the coolest easter eggs in R language.

if (!require("pacman")) install.packages("pacman")
pacman::p_exists(R)

There are several other easter eggs in R listed on Inside-r.org; a few are copied below for your fun:

# install and/or load dependencies for the easter eggs
pacman::p_load(animation, rgdal, PBSmodelling, onion, mapview)

Easter Eggs in Help Pages

A funny note about the locatoin data quality pops up in this help page and gives some pretty good advice regarding air travel.

?rgdal::project

Fair warning regarding the dangers of playing with internals.

?.Internal

Console Easter Eggs

These are a bit of wRy console humor:

????t.test

example(readline)  # type n as input

Another easter egg viz, of sorts

local(envir=.PBSmodEnv,expr={
  oldpar = par(no.readonly=TRUE)
  x=rnorm(5000,10,3); y=-x+rnorm(5000,1,4); z=x+rnorm(5000,1,3)
  A=data.frame(x=x,y=y,z=z)
  for (i in 1:3)
    switch(i,
           {plotFriedEggs(A,eggs=TRUE,rings=FALSE);
             pause("Here are the eggs...(Press Enter for next)")},
           {plotFriedEggs(A,eggs=FALSE,rings=TRUE);
             pause("Here are the rings...(Press Enter for next)")},
           {plotFriedEggs(A,eggs=FALSE,rings=FALSE);
             cat("Here is the pepper alone.n")} )
  par(oldpar)
})


data(bunny); p3d(bunny,theta=3,phi=104,box=FALSE)

mapview()

masthead image altered from screenshot of original pacman imulator

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

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.