Hi, I cannot save a deck of cards and related functions from global environment into runtime environment. I downloaded the deck of cards from the website https://gist.github.com/garrettgman/9629323
Code for saving the deck into runtime environment
setup <-function(deck) {
DECK <- deck
DEAL <- function () {
card <- deck[1,]
assign ("deck", deck[-1,], envir =globalenv())
card
}
SHUFFLE <- function () {
random <- sample (1:52, size = 52)
assign ("deck", DECK[random, ], envir =globalenv())
}
}
setup
setup <-function(deck) {
DECK <- deck
DEAL <- function () {
card <- deck [1,]
assign ("deck", deck[-1,], envir =globalenv())
card
}
SHUFFLE <- function () {
random <- sample (1:52, size =52)
assign ("deck", DECK[random, ], envir =globalenv())
}
list (deal = DEAL, shuffle = SHUFFLE)
}
deal <- cards$deal
shuffle <- cards$shuffle
When I check for the environment where deal is saved I get still the global environment.
environment (deal)
Could you please help me?
Thank you and best, Svita