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:
# 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)
|
Output:
sin(23) cos(0) [1] -0.8462204 [1] 1
Example 2:
# R program to illustrate # call function # Calling call() function x < - call( "round" , 10.5 )
x # Initializing a round character f < - "round"
# Calling call() function call(f, quote(A)) |
Output:
round(10.5) round(A)
Example 3:
# 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)) |
Output:
Error in call(f, quote(A)) : first argument must be a character string Execution halted