Intro to R and a Gambling Demo

I gave a 50-minute presentation at SUNY Fredonia’s Spring 2016 Faculty Professional Development Day. It was a very nice experience. Of course, I prepared way more content than was reasonable for a 50-minute presentation, but I think it went well, anyway. Here is the presentation (PowerPoint; I¬†know all the cool R people use LaTeX for their R presentation slides, but… ).

One thing I did not do in the presentation was a demo I created for simulating 100,000 games of Twenty-One against a dealer, when you have a “hold rule” of 18 or higher, and the dealer has a rule of 17 or higher. It’s over-simplified: Aces always count as 1, and there are only two card draws after the initial deal. However, I think it is at least a little bit fun.

At some point I should go back and add the possibility of Aces being 1 or 11, and also make the output at each step pretty. But for an intro workshop this seemed appropriate, if too long-winded for a 50-minute session. The code is after the break. Continue reading Intro to R and a Gambling Demo

R for Teaching: Visualize a z-test

I occasionally write functions in R to help me with some aspect of teaching, usually teaching undergrad stats. I always intend to share them with others, but I don’t actually know many other people who use R for teaching. So why not share in blog posts? I’ll start now.

Disclaimer: This functions is untested by anyone but me, it might not work, and I provide no guarantee of accuracy. I mean, I try, but you know…

An R function for visualizing single-sample z-tests, a function I named zvis, produces graphs as below, using (usually) pretty simple options:

zvis(x=104, mu0=100, sigma=15, n=30)

I won’t paste the code here because it’s kind of long, but anyone interested can have it from this link –> zvis. The whole set of arguments can be seen after the break. If, by chance, anyone is interested in this function and wants more explanation of these options, or has suggestions for improving the function, please let me know. Continue reading R for Teaching: Visualize a z-test