-
-
Save garrettgman/9629323 to your computer and use it in GitHub Desktop.
face | suit | value | |
---|---|---|---|
king | spades | 13 | |
queen | spades | 12 | |
jack | spades | 11 | |
ten | spades | 10 | |
nine | spades | 9 | |
eight | spades | 8 | |
seven | spades | 7 | |
six | spades | 6 | |
five | spades | 5 | |
four | spades | 4 | |
three | spades | 3 | |
two | spades | 2 | |
ace | spades | 1 | |
king | clubs | 13 | |
queen | clubs | 12 | |
jack | clubs | 11 | |
ten | clubs | 10 | |
nine | clubs | 9 | |
eight | clubs | 8 | |
seven | clubs | 7 | |
six | clubs | 6 | |
five | clubs | 5 | |
four | clubs | 4 | |
three | clubs | 3 | |
two | clubs | 2 | |
ace | clubs | 1 | |
king | diamonds | 13 | |
queen | diamonds | 12 | |
jack | diamonds | 11 | |
ten | diamonds | 10 | |
nine | diamonds | 9 | |
eight | diamonds | 8 | |
seven | diamonds | 7 | |
six | diamonds | 6 | |
five | diamonds | 5 | |
four | diamonds | 4 | |
three | diamonds | 3 | |
two | diamonds | 2 | |
ace | diamonds | 1 | |
king | hearts | 13 | |
queen | hearts | 12 | |
jack | hearts | 11 | |
ten | hearts | 10 | |
nine | hearts | 9 | |
eight | hearts | 8 | |
seven | hearts | 7 | |
six | hearts | 6 | |
five | hearts | 5 | |
four | hearts | 4 | |
three | hearts | 3 | |
two | hearts | 2 | |
ace | hearts | 1 |
@hdshovel Click on Import Dataset in the Environment tab, then click From Text (readr)... Then paste the URL into the first field, which is the one labelled File/URL. Good luck!
Ah, really awesome way to import a dataset. the book is fantastic.
Hi, I cannot store deck and related functions into runtime environment (pages 107-110 of the book).
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 enter deal now, I get as a result NULL. When I check the environment(deal) I still get the global environment.
Please kindly help me. Thank you and best, Svita
Garret,
This is a phenomenal piece of literature. Your approach is top-notch. Just about every abstract concept, that would normally scare people away, was concretized. I hope this book gets the recognition it deserves. Thanks
Great Book! Thanks!!
Thank you. It´s a great book.
Great book! Loving it xdd
Hello, first of all, your book is excellent!
I had a doubt regarding the Exercise on Page 73 of the book where we are asked to write the shuffle function. While we do get a random card(row) on running the function deal(deck2), on running the function multiple times, I get the same card (row) again and again, is this okay or have I made a mistake?
Thank you!
The new shuffle() card isn't getting saved into a new deck. Completely normal, the author teaches you in the next couple sections the best way to go about it. Happy coding!
The new shuffle() card isn't getting saved into a new deck. Completely normal, the author teaches you in the next couple sections the best way to go about it. Happy coding!
Thank you for the clarification!
Hello, I had a question regarding viewing R's environment system. I installed and loaded both the usethis and the devtools package, however, when I run the function parenvs(all = TRUE), I get the error message - "Error in parenvs(all = TRUE) : could not find function "parenvs"".
Thank you!
"Error in parenvs(all = TRUE) : could not find function "parenvs""
Okay, so it looks like that the parenvs() function has been removed from devtools, because it is now in the pryr package. Thanks!
Welcome to coding, you ask and answer a question, cause in the end they're all just a bunch of hexcodes firing around somewhere.
If you have trouble with environments, try switching your IDE. Currently I'm using PyCharm, which is a python compiler with lots of R addons, easy to use once you get the hang of it ✌
Hello, I have a question.
As described on Page 106, when we write the following function -
deal <- function() {
card <- deck[1, ]
assign("deck", deck[-1, ], envir = globalenv())
card
}
Why is the card on top of the deck different every time we run deal( )? There has been no mention of random, as we did in the shuffle function, which would re-arrange the cards in a random order? Thank you!
@Rawlley27 this line
assign("deck", deck[-1, ], envir = globalenv())
updates deck
to contain everything except the top card, which has now been "dealt".
@Rawlley27 this line
assign("deck", deck[-1, ], envir = globalenv())
updates
deck
to contain everything except the top card, which has now been "dealt".
Thank you for your reply! I get it now, we are getting things in order every time we run this function, queen followed by jack and so on... Thank you again for clarifying!!
Hello, I had a question, in the following code on page 127
same <- symbols[1] == symbols[2] && symbols[2] == symbols[3]
why are there two & symbols? I know the meaning of one & but why are there two? Thank you!!
Hello, I had a question, in the following code on page 127
same <- symbols[1] == symbols[2] && symbols[2] == symbols[3]why are there two & symbols? I know the meaning of one & but why are there two? Thank you!!
okay, I just read the next page of the book which clarified my doubt, thank you!
Hello, On page 134, it should be "And when cherries equal two" and not three. The cherries equal three scenario should be taken care of by Case 1 where we have three of the same symbol.
And when cherries equals three, we have:
cherries + 1
3
c(0, 2, 5)[cherries + 1]
5
I just wanted to clarify this, please do correct me if I am wrong. Thank you!
Your book really help to start R programming: smooth and progressive approach!
That is great book. Thank you !
Thank you for the book, and for making it available for free. Really appreciated.
I'm really thankful
Thank you for putting this together. Going through it now
This is a really engaging course and got me excited to learn. Thanks a lot!
Thank you!
Muchas GRACIAS Sr. Garrett !!
El libro está BIEN PADRE e INTERESANTE, APRENDE UNO RÁPIDO... es la primera vez que aprendo a programar.
DIOS lo bendiga siempre!!
Carlos
Hi Felipe, I don't know if its too late, but I had a similar problem and thought that, since you have a Spanish name, like I do, our problem had something to do with the region where we are located. Indeed I found a solution. The problem is that the default separator for Spanish speaking regions is a semicolon (;), not a comma. Hence, when you download the data to Excel it will change some of the quotation marks and commas. To solve this issue you can follow the instructions in this link: https://harvestmedia.zendesk.com/hc/en-us/articles/360023978031-Opening-Excel-files-with-the-correct-CSV-list-separator#:~:text=CSV%20(comma%20delimited)%20will%20not,comma%20separator%20or%20semicolon%20separator.
I think that this may help other Spanish speaking people encountering a similar problem in the future.
I hope it helps.
Is it just me, or are there others who are bothered by the "value" for "jack", "queen", and "king" being set to "11, 12, and 13" respectively?
Perhaps there is some other use that will be made of the "value" numbers, but that should be pointed out right here and now.
I loaded the CSV file into EXCEL and changed those values to all be "10." I did this for the obvious reason.
@Jfelipelaverde it seems to me that you may not be clicking the correct options in the RStudio IDE Import Data Wizard (this step), but it is hard for me to tell. Be sure that you are choosing
Separator: Comma
.