The “cos” Function in R
Package: Base R (No specific package, it’s a built-in function)
Purpose: To compute the cosine of a numeric vector, interpreting the input as angles in radians.
General Class: Mathematical Computation
Required Argument(s):
x: A numeric vector representing angles in radians for which the cosine is to be computed.
Notable Optional Arguments:
None
Example:
# Example usage
angles_in_radians <- c(0, pi/2, pi, 3*pi/2, 2*pi)
# Compute the cosine
cos_values <- cos(angles_in_radians)
print(cos_values)In this example, cos is a built-in function in base R, and it is used to compute the cosine of a numeric vector representing angles in radians. The x argument is the required numeric vector for which the cosine is calculated. There are no notable optional arguments for this function. The result is a numeric vector where each element represents the cosine of the corresponding angle in the input vector.