Skip to content

Instantly share code, notes, and snippets.

@nozma
Created July 5, 2016 15:08
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 nozma/4637174f3419692d3359c242ca3e69f1 to your computer and use it in GitHub Desktop.
Save nozma/4637174f3419692d3359c242ca3e69f1 to your computer and use it in GitHub Desktop.
Rプログラミング入門第6章用準備ファイル
# read "deck" dataframe
deck <- read.csv("https://gist.githubusercontent.com/garrettgman/9629323/raw/ee5dfc039fd581cb467cc69c226ea2524913c3d8/deck.csv")
DECK <- deck
# define functions
roll <- function(){
die <- 1:6
dice <- sample(die, size = 2, replace = TRUE)
sum(dice)
}
deal <- function(cards){
cards[1, ]
}
shuffle <- function(cards){
random <- sample(1:52, size = 52)
cards[random, ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment