n
naseer mohammad

Posted on 19th April 2024|68 views

0
votes

Unused Argument

Will R ignore the unused arguments?

in R is it possible to ignore the unused arguments, for example, I have a module add(x,y) which returns the sum of x and y but the code is.

add(x=10, y=30, c=5)

It returns an error.

 

Answers
P
James ROBERT

Posted on 19th April 2024

To avoid the error you can simply add dots in the function definition just like this:

 add <- function(x, y, ...){ 

cat(x,y) }

 myfun(x=4,y=7,hello=3)

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos