The asin() function in R calculates the arcsine of a numeric input. The arcsine is the inverse operation of the sine function, and it returns the angle in radians whose sine is the given number.
Syntax
asin(number)
Parameters
number: It is a numeric value.
Return value
It returns the inverse sine of a number. The return value lies in the interval [-pi/2, pi/2] radians.
Example 1: Usage of asin()
v1 <- -1
v2 <- 0.5
v3 <- 0
asin(v1)
asin(v2)
asin(v3)
Output
[1] -1.570796
[1] 0.5235988
[1] 0
Example 2: Using vector
vec <- c(-1, 0.5, 0, 0.5, 1)
asin(vec)
Output
[1] -1.5707963 0.5235988 0.0000000 0.5235988 1.5707963
Example 3: Passing float values
# Positive float value
data_one <- asin(0.9)
print(paste0("asin(0.9): ", data_one, " radians"))
# Negative float value
data_two <- asin(-0.75)
print(paste0("asin(-0.75): ", data_two, " radians"))
# Applying asin() and then converting the result in radians to degrees
data_three <- asin(0.45) * (180.0 / pi)
print(paste0("asin(0.45): ", data_three, " degrees"))
Output
[1] "asin(0.9): 1.11976951499863 radians"
[1] "asin(-0.75): -0.848062078981481 radians"
[1] "asin(0.45): 26.743683950403 degrees"
Example 4: Plotting
vec <- seq(-1, 1, by = 0.05)
plot(dt, asin(vec), typ = "l", col = "red")
abline(v = 0, lty = 6, col = "blue")
Output
That is it.
Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.