logo-MindMajix
n
naseer mohammad

Posted on 23rd June 2024|72 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.

 

1 answers
Answers
P
James ROBERT

Posted on 23rd June 2024| views

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
Name
Course *
Email *
Phone Number