Create an Object of mode call in R Programming – call() Function

call() function in R Language is used to create or test for objects of mode “call”.

Syntax: call(name, …)

Parameters:
name: a non-empty character string naming the function to be called
…: arguments to be part of the call

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# call function
  
# Calling call() function
x <- call("sin", 23)
y <- call("cos", 0)
x
y
  
# Evaluating values of call
eval(x)
eval(y)

chevron_right


Output:



sin(23)
cos(0)
[1] -0.8462204
[1] 1

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# call function
  
# Calling call() function
x <- call("round", 10.5)
  
# Initializing a round character
f <- "round"
  
# Calling call() function
call(f, quote(A)) 

chevron_right


Output:

round(10.5)
round(A)

Example 3:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# call function
  
# Initializing round value
# without its character
f <- round
  
# Calling call() function
# which will give an error
# bcs the argument should be
# a character string
call(f, quote(A))

chevron_right


Output:

Error in call(f, quote(A)) : first argument must be a character string
Execution halted



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.