• About
  • Articles
  • Books
    • The Bestseller Code
    • Text Analysis with R for Students of Literature
    • Macroanalysis
      • Confusion Matrices
      • Expanded Stopwords List
      • The LDA Buffet: A Topic Modeling Fable
      • 500 Themes
      • Color Versions of Figures 9.3 and 9.4
  • Courses
  • Lectures/Events
  • Papers
  • Workshops
    • University of Chicago (2019)
    • University College London (May 10, 2017)
    • Vanderbilt (April 5, 2017)
    • Wesleyan (March 3, 2017)
    • National Humanities Center: June 8 – 12
      • Day One Code
      • Day Two Code
      • Day Three Code
      • Day Four Code
      • Day Five Code
      • Year Two Instructions
      • Year Two XML
    • Harvard: April 3, 2015
    • Yale: December 5, 2014
    • DH 2014: Introduction to Text Analysis and Topic Modeling with R
    • University of Gothenburg
    • Michigan State University
    • University of Kansas
    • UW-Milwaukee, 2013
      • Workshop Code
    • 2013 DHWI
      • DHWI: R Code Day One
      • DHWI: R Code Day Two
      • DHWI: R Code Day Three
      • DHWI: R Code Day Four
      • DHWI: R Code Functions File
    • 2013 MLA/DH Commons
  • Noted

Matthew L. Jockers

Category Archives: Just for Fun

A Festivus Miracle: Some R Bingo code

09 Monday Dec 2013

Posted by Matthew Jockers in Just for Fun, R-Code, Tips and Code

≈ Comments Off on A Festivus Miracle: Some R Bingo code

A few weeks ago my daughter’s class was gearing up to celebrate the Thanksgiving Holiday, and I was asked to help prepare some “holiday bingo cards” for the kid’s party. Naturally, I wrote a program in R for the job! (I know, I know, Maslow’s hammer)

Since I learned a few R tricks for making a grid and placing text, and since today is the first day of the Hour of Code, I’ve decided to release the code;-)

The 13 lines (excluding comments) of code below will produce 25 random Festivus Bingo Cards and write them out to a single pdf file for easy printing. You supply the Festivus Nog.

bingo.cards.script.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# file to make random holiday bingo boards in R. . .
 
# How many different cards do you want to make?
num.unique.bingo.cards<-25
 
# 25 words to populate the board with:
my.words<-toupper(c("Seinfeld", "Costanza", "Festivus", "Kramer", "pole", "Grievances", "Strength", "meatloaf", "wrestling ", "Miracle", "Elaine", "Jerry","George", "Dinner", "NBC","December", "Sitcom", "1997", "two-face", "donation", "Kruger", "Flask", "Strike", "Submarine", "Gwen"))
 
# Put it all in a single pdf file for easy printing!
pdf("bingo.cards.pdf", width=7.5, height=7.5)
for(i in 1:num.unique.bingo.cards){
  # Build a 5 x 5 Matrix for the Grid; ignore the warnings:-)
  m <- matrix(0:1, nrow=5, ncol=5)
  image(m, col=c("darkgreen", "red"), xaxt="n", yaxt="n", main="Festivus Bingo")
  the.vals<-c(0, .25, .5, .75, 1,1, .75, .5, .25, 0)
  x.y.vals<-combn(the.vals, 2)
  the.coords<-unique(t(x.y.vals))
  word.sample<-sample(my.words)
  text(the.coords, word.sample, col="white", cex=.75)
}
dev.off()

♣ Contact

head shot
Matthew L. Jockers

Professor of English and Data Analytics
Washington State University
PO Box 642630 | Pullman, WA 99164-2630
509-335-5540 | matthew.jockers@wsu.edu

ORCID iD iconhttps://orcid.org/0000-0001-5599-3706

 

Twitter: @mljockers
Amazon Author Profile
Goodreads Author Profile

Also See: Authors A.I.

♣ On Quantification:

". . . everything . . . in nature's vast workshop from the extinction of some remote sun to the blossoming of one of the countless flowers which beautify our public parks is subject to a law of numeration as yet unascertained.” (Joyce, Ulysses, 1922)

♣ Recent Comments

  • An Interview with Matthew Jockers | What Is A Media Lab? on Macroanalysis
  • What Is A Media Lab? on Text Analysis with R for Students of Literature
  • Matthew Jockers | Digital Arts & Humanities at Harvard University on Text Analysis with R for Students of Literature
  • Introduction to Digital Humanities | Intro to DH on 500 Themes
  • Early Christian Monasticism in the Digital Age | First foray into topic modeling on Text Analysis with R for Students of Literature

♣ Archives

♣ Blogroll

  • Ben Schmidt
  • Matthew Sag
  • Scott B. Weingart
  • Stéfan Sinclair
  • Stephen Ramsay
  • Ted Underwood

♣ Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Creative Commons License
This work by Matthew Jockers is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

Proudly powered by WordPress Theme: Chateau by Ignacio Ricci.