Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active September 16, 2022 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdsumner/8962222440cc9922df91eb6288dd81c0 to your computer and use it in GitHub Desktop.
Save mdsumner/8962222440cc9922df91eb6288dd81c0 to your computer and use it in GitHub Desktop.

here's the content of a SO deletion by a sanctimonius obstructionist.

I think I've seen an Easter egg or two in some R packages, but I am not able to recall them.

Here are a few from Matlab, and more here, if you want to see some examples of Easter eggs.

Are there any known Easter eggs in R or some of the major packages?

(If justification is really necessary...the reason for asking is simple: some of the Easter eggs for Matlab demonstrate useful functionality and happen to be amusing. I'm not particularly enamored with their "default image" Easter egg, but the examples for simulations (e.g. life and toilet) are actually useful for code and pedagogical purposes. Not all demos need to be dry.)

Update 1: I apologize to any developers offended by this, but my interest is in widely distributed R packages, as it's not that hard to create an Easter egg and drop the package into CRAN. While examples like this "fried eggs" plot and this bunny are a bit amusing, they're not in particularly common packages, as far as I'm aware. However, finding that fried eggs plot did introduce me to the PBSmodelling package which looks rather helpful for other reasons. (RseekAndYouShallFind...some odd stuff.)

Update 2: example(readline) is iffy. It's the closest I found in a scan of the base R code.

@mdsumner
Copy link
Author

comments on the OP

Oops. 10 more letters... – 
[rlb.usa](https://stackoverflow.com/users/449902/rlb-usa)
 [Oct 26, 2011 at 23:51](https://stackoverflow.com/questions/7910270/are-there-any-easter-eggs-in-base-r-or-in-major-packages#comment9660045_7910270) 
2

running find . -name "*.R" -exec grep -iH "silly\|crazy\|weird\|funny\|stupid" {} \; on the R source tree is somewhat interesting ... – 
[Ben Bolker](https://stackoverflow.com/users/190277/ben-bolker)
 [Oct 27, 2011 at 4:05](https://stackoverflow.com/questions/7910270/are-there-any-easter-eggs-in-base-r-or-in-major-packages#comment9661979_7910270)

I did all but weird, crazy, and stupid. :) I also tried "joke", "amus" (for amuse/amusing), "fun" (oh the fun...), "toy", "surprise", "!", "easter", "egg", and some others. I thought about warning someone off of this, but I didn't want to seem too meticulous in hunting Easter eggs. Now my secret is revealed. :) – 
[Iterator](https://stackoverflow.com/users/805808/iterator)
 [Oct 27, 2011 at 4:07](https://stackoverflow.com/questions/7910270/are-there-any-easter-eggs-in-base-r-or-in-major-packages#comment9661993_7910270)

@mdsumner
Copy link
Author

an answer, by some whacker

This answer is hidden. This answer was deleted 8 years ago along with its parent question.
How about this in 32-bit R:

memory.limit(4096)
Error in memory.size(size) : 
 don't be silly!: your machine has a 4Gb address limit
[Share](https://stackoverflow.com/a/7910358/355270)
[Edit](https://stackoverflow.com/posts/7910358/edit)
Undelete
Flag
answered Oct 27, 2011 at 0:01

comments

That certainly qualifies. I have repressed memories of R mocking me: I suspect that might be the Easter egg I was thinking of. :) What's more it is is informative and helpful (I got off of 32-bit R as fast as I could). – 
[Iterator](https://stackoverflow.com/users/805808/iterator)
 [Oct 27, 2011 at 1:08](https://stackoverflow.com/questions/7910270/are-there-any-easter-eggs-in-base-r-or-in-major-packages#comment9660706_7910358) 
I'm sure there are some good data ones, but apart from fortunes() I've got nothing else. – 
[mdsumner](https://stackoverflow.com/users/355270/mdsumner)
 [Oct 27, 2011 at 1:13](https://stackoverflow.com/questions/7910270/are-there-any-easter-eggs-in-base-r-or-in-major-packages#comment9660747_7910358)

@mdsumner
Copy link
Author

Yihui

Does one of the demos in the [animation](http://cran.r-project.org/package=animation) package qualify as an Easter egg?

library(animation)
demo(package = 'animation')
## e.g. demo('fire') or demo('Mandelbrot') or demo('game_of_life')
Perhaps you can take a look at the [fun](http://cran.r-project.org/package=fun) package as well.

[Share](https://stackoverflow.com/a/7911018/355270)
[Edit](https://stackoverflow.com/posts/7911018/edit)
Follow
Undelete
Flag
answered Oct 27, 2011 at 2:10
[Yihui Xie](https://stackoverflow.com/users/559676/yihui-xie)'s user avatar
Yihui Xie
26.9k2222 gold badges186186 silver badges409

comments

I was about to say they're not Easter eggs, because they're documented, but now I see the wild and crazy developer ;-) didn't document these. Thanks for the suggestions. These certainly demonstrate interesting functionality. Also, what is this [shutdown.R function](https://github.com/yihui/fun/blob/c0ca795ce81b3949680d007848580b4b6bd38ac0/R/shutdown.R)? That looks, ummm, wild. :) (I see it's described [here](http://cos.name/en/topic/shut-down-your-windows-with-r).) – 
[Iterator](https://stackoverflow.com/users/805808/iterator)
 [Oct 27, 2011 at 2:21](https://stackoverflow.com/questions/7910270/are-there-any-easter-eggs-in-base-r-or-in-major-packages#comment9661232_7911018)

@mdsumner
Copy link
Author

Joshua

This answer is hidden. This answer was deleted 8 years ago along with its parent question.
I've found some comments in R's C code to be very amusing. Here are a couple:

In src/main/engine.c:

/* A note on memory management ...
 * Here (with GEDevDesc's) I have continued the deplorable tradition of
 * malloc'ing device structures and maintaining global variables to
 * record the device structures.  I believe that what I should
 * be doing is recording the device structures in R-level objects
 * (i.e., SEXP's) using Luke's reference pointers to make sure that
 * nasty things like duplicate copies of device structures do not
 * occur.  The thing stopping me doing "the right thing" right now
 * is time.  Hopefully, I will get time later to come back and do
 * it properly -- in the meantime I'll just have to burn in hell.
 * Paul.
 */
And while I was searching for that, I found this in src/library/grDevices/src/devQuartz.c:

void QuartzDevice_RestoreSnapshot(QuartzDesc_t desc, void* snap)
{
    QuartzDesc *qd = (QuartzDesc*) desc;
    pGEDevDesc gd  = GEgetDevice(ndevNumber(qd->dev));
    if(NULL == snap) return; /*Aw, hell no!*/
    PROTECT((SEXP)snap);
    if(R_NilValue == VECTOR_ELT(snap,0))
        warning("Tried to restore an empty snapshot?");
    qd->redraw = 1;
    GEplaySnapshot((SEXP)snap, gd);
    qd->redraw = 0;
    qd->dirty = 0; /* we reset the dirty flag */
    UNPROTECT(1);
}
Found another one in src/main/Rstrptime.h:

/* Oh come on.  Get a reasonable compiler.  */
[Share](https://stackoverflow.com/a/7912390/355270)
[Edit](https://stackoverflow.com/posts/7912390/edit)
Follow
Undelete
Flag
[edited Nov 4, 2011 at 5:33](https://stackoverflow.com/posts/7912390/revisions)
answered Oct 27, 2011 at 6:27
[Joshua Ulrich](https://stackoverflow.com/users/271616/joshua-ulrich)'s user avatar
Joshua Ulrich
170k2929 gold badges327327 silver badges410
Following this thread (and @mdsumner's answer) I suppose that the [comment for ?.Internal](http://stackoverflow.com/questions/7327521/reference-for-r-wizards) may qualify as an Easter egg. The code isn't documented, isn't amusing per se (the help is amusing), yet it does provide hours of joy. I won't add it to the list of answers, but [you're certainly to credit](http://stackoverflow.com/questions/7326865/in-r-how-can-i-check-if-two-variable-names-reference-the-same-underlying-object/7327426#7327426) for putting me on the hunt for wizaRdry and horcruxes. – 
[Iterator](https://stackoverflow.com/users/805808/iterator)
 [Oct 27, 2011 at 12:08](https://stackoverflow.com/questions/7910270/are-there-any-easter-eggs-in-base-r-or-in-major-packages#comment9667453_7912390)

@mdsumner
Copy link
Author

whacker again

This answer is hidden. This answer was deleted 8 years ago along with its parent question.
In the rgdal package, with a Note about the example locations used:

?rgdal::project


 Note:

 The locations of Hawaii and Alaska in the data source are (putting
 it mildly) arbitrary, please avoid airlines using these positions.
[Share](https://stackoverflow.com/a/7915520/355270)
[Edit](https://stackoverflow.com/posts/7915520/edit)
Undelete
Flag
answered Oct 27, 2011 at 11:57
[mdsumner](https://stackoverflow.com/users/355270/mdsumner)'s user avatar
mdsumner
28.5k66 gold badges8080 silver badges88

@mdsumner
Copy link
Author

Henrik

This answer is hidden. This answer was deleted 8 years ago along with its parent question.
Try a search, not with ? or ?? but with ???? (or more ?:s),e.g. ????"t.test".

[Share](https://stackoverflow.com/a/9483354/355270)
[Edit](https://stackoverflow.com/posts/9483354/edit)
Follow
Undelete
Flag
answered Feb 28, 2012 at 14:04
[Henrik R](https://stackoverflow.com/users/1238042/henrik-r)'s user avatar
Henrik R
20122 silver badges2
Ha ha ha ha! That's good. – 
[Iterator](https://stackoverflow.com/users/805808/iterator)
 [Feb 28, 2012 at 19:59](https://stackoverflow.com/questions/7910270/are-there-any-easter-eggs-in-base-r-or-in-major-packages#comment12011256_9483354) 

Yes, indeed that is good. – 
[wahalulu](https://stackoverflow.com/users/142068/wahalulu)
 [Apr 13, 2012 at 17:43](https://stackoverflow.com/questions/7910270/are-there-any-easter-eggs-in-base-r-or-in-major-packages#comment13009437_9483354)

I spent a while searching for the source code for this. It can be viewed by typing utils::"?" in the console – 
[Flounderer](https://stackoverflow.com/users/1713297/flounderer)
 [May 24, 2013 at 2:18](https://stackoverflow.com/questions/7910270/are-there-any-easter-eggs-in-base-r-or-in-major-packages#comment24085436_9483354)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment