-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deal <- function(cards) in 6.2 Deal a Card #66
Comments
Hello,
This function expect two arguments to work with and add them together, x and y doesn't have to be defined previously to use the function. But if they are not defined previously you must defined them when calling the sum2num function or you will get an error:
The proper way to use this function is defining the arguments when calling it:
So, you may already notice why are you getting an error, you must give a value to the argument cards of the deal function when calling the function:
(Note: The previous solution assume you have created the deck object) |
Hi, Thanks for the clarification, what confused me was that we have a cards.csv, saved as per the documentation, and I was wondering whether it did have anything to do w/ that name… Anyway, now it is clear. Thanks again for your clarification.
Best regards,
Soumya
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
From: ***@***.***>
Sent: Monday, January 16, 2023 12:16 PM
To: ***@***.***>
Cc: ***@***.***>; ***@***.***>
Subject: Re: [rstudio-education/hopr] deal <- function(cards) in 6.2 Deal a Card (Issue #66)
Hello,
When creating a function the arguments of it are defined between parentheses separated by commas. For example:
sum2num <- function (x, y){
x + y
}
This function expect two arguments to work with and add them together, x and y doesn't have to be defined previously to use the function. But if they are not defined previously you must defined them when calling the sum2num function or you will get an error:
sum2num()
## Error in sum2num(): argument "x" is missing, with no default
The proper way to use this function is defining the arguments when calling it:
sum2num(x=1, y=2)
## [1] 3
So, you may already notice why are you getting an error, you must give a value to the argument cards of the deal function when calling the function:
deal(cards = deck)
—
Reply to this email directly, view it on GitHub<#66 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALL4L674SKVCXR6YW26A7CLWSV7ALANCNFSM6AAAAAAT46Q5KE>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
I am a beginner and 'am very impressed with the book's method of teaching. I think it would help if you explained why you used function(cards), as "cards" itself was not defined as a variable before this use
deal <- function(cards) {
?
}
and followed by...
deal <- function(cards) {
cards[1, ]
}
For e.g. if we run > deal(), gives the following error...
Error in deal() : argument "cards" is missing, with no default
The text was updated successfully, but these errors were encountered: