Created
July 5, 2016 15:08
-
-
Save nozma/4637174f3419692d3359c242ca3e69f1 to your computer and use it in GitHub Desktop.
Rプログラミング入門第6章用準備ファイル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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