R Tutorial R Charts & Graphs R Statistics R References

R - asin() Function



The R asin() function returns arc sine of a value. The returned value will be in the range -𝜋/2 through 𝜋/2. In special cases it returns the following:

  • If the argument is NaN or its absolute value is greater than 1, then the result is NaN.

Note: asin() is the inverse of sin().

Syntax

asin(x)

Parameters

x Required. Specify column to compute on.

Return Value

Returns the arc sine of the value.

Example:

In the example below, asin() function is used to find out the arc sine of the value.

#operating on single element atomic vector
print(asin(-0.5))
print(asin(0))
print(asin(0.5))

cat("\nOperating on vector\n")
#operating on vector
v <- c(0, 0.25, 0.5)
print(asin(v))

cat("\nOperating on matrix\n")
#operating on matrix
m <- matrix(c(-1, -0.5, 0, 0.5, 1, NaN), nrow=2)
print(asin(m))

cat("\nOperating on first column of matrix\n")
#operating on first column of matrix
print(asin(m[,1]))

The output of the above code will be:

[1] -0.5235988
[1] 0
[1] 0.5235988

Operating on vector
[1] 0.0000000 0.2526803 0.5235988

Operating on matrix
           [,1]      [,2]     [,3]
[1,] -1.5707963 0.0000000 1.570796
[2,] -0.5235988 0.5235988      NaN

Operating on first column of matrix
[1] -1.5707963 -0.5235988

❮ R Math Functions