![]() ![]() The response I received was as follows: “Don’t subset args with character vectors. I posted a question on the Coursera Swirl forum. | and assign them to variables, then pass those variables to paste(). | Your function should have three sections: capture the ellipsis in a list(), unpack the arguments from the ellipsis Paste(“News from”, place, “today where”, adjective, “students took to the streets in protest of the new”, noun, “being installed on campus.”)Ĭ:\Users\Matthew\AppData\Local\Temp\RtmpshBSkp/mad_libs.R:40:2: unexpected symbolģ9: paste(“News from”, place, “today where”, adjective, “students took to the streets in protest of the new”, noun, “being installed on campus.”) # Notice the variables you’ll need to create in order for the code below to # Don’t modify any code below this comment. Here is the code I have written (which I believe matches yours): I have been stuck for a few hours this afternoon on Swirl lesson 9 (“unpack” arguments). I am working my way through Swirl exercises as part of the Coursera R programming course. | Make sure to delete the pound sign so the last expression in the function is just x. | That’s not the answer I was looking for, but try again. Save this script and type submit() in the console after you make your changes. The argument x as input, and returns the value of x without modifying it.ĭelete the pound sign in front of the x to make the function work! Be sure to After sourcing the function, you can use theīelow we will create a function called boring_function. arg1 andĪrg2 represent the arguments of your function. The “variable name” you assign will become the name of your function. To a variable with the assignment operator, you assign functions in the following You’re about to write your first function! Just like you would assign a value Do you know what’s wrong with the code? Thanks! I’m having problems with the 15% assignment of this lesson (writting the first function). (To block quote your code in this WordPress blog post comment, just add three back ticks above and below the code.) in the case when adjective is mis-spelled as adjustive, please do share! If you / anyone can think of a simple (new or existing) way to make R throw up an error in the event of input not defined (e.g. Net net, it looks like the current mad_libs() function runs, regardless of whether an input is defined or not. "News from London today where beautiful students took to the streets in protest of the new dog being installed on campus." Which will output the correct expected result: Mad_libs(place = "London", adjective = "beautiful", noun = "dog") ![]() The calling of function should really be corrected to: "News from London today where students took to the streets in protest of the new dog being installed on campus." ![]() It will output an incorrect result (As it doesn’t know what adjustive is) Will still run in RStudio (no idea why?). Mad_libs(place = "London", adjustive = "beautiful", noun = "dog") Great spot! I just realized I made a typo when invoking the mad_libs function! (The function is written correctly, but the calling of function contains one typo: the inpput adjustive should be corrected to adjective. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |