blog

Making Holiday Cards in R 2018

With the holiday season coming up, we want our first R-Ladies Baltimore coding project in R to be get into small groups and create holiday designs in R. Here are a few examples: Happy Holidays from Rafael Irizarry The main part of the code looks like this: N <- 120 par(bg="black") h <- rep(c(2:4,7),N/3) h[sample(N,N/5)] <- 0 plot((-2)^as.complex(seq(1,49,len=100)^0.5), pch=21,bg=h,xlab="", ylab="", xaxt="n",yaxt="n", cex=1.5) text(-25,50,"Happy Holidays!",cex=2,col=ifelse(h%%2,"white","black")) Make a Christmas Tree in R with random ornaments/presents # Make the canvas plot(1:10,1:10,xlim=c(-5,5),ylim=c(0,10),type="n",xlab="",ylab="",xaxt="n",yaxt="n") # Make the branches rect(-1,0,1,2,col="tan3",border="tan4",lwd=3) polygon(c(-5,0,5),c(2,4,2),col="palegreen3",border="palegreen4",lwd=3) polygon(c(-4,0,4),c(3.