How to Perform Arcsine Transformation in R?
Last Updated :
19 Dec, 2021
In this article, we will discuss how to perform arcsine transformation in R programming language.
Arcsine transformation is used to extend the data points in the range of 0 -1
Syntax:
asin(sqrt(data))
where, data belongs to range of values from 0 to 1
Arcsine Transformation of Values in Range 0 to 1
Here we are going to create a vector with values between the given range and perform the arcsine transformation.
Example: Arcsine Transformation
R
data= c (0.3,0.2,0.4,0.5,0.6,0.7,0.8,0.34)
print (data)
print ( asin ( sqrt (data)))
|
Output:
[1] 0.30 0.20 0.40 0.50 0.60 0.70 0.80 0.34
[1] 0.5796397 0.4636476 0.6847192 0.7853982 0.8860771 0.9911566 1.1071487
[8] 0.6225334
Arcsine Transformation of Values in DataFrame
Here we are going to consider the dataframe to get arcsine transformation of the dataframe
Example: Arcsine Transformation
R
data= data.frame (col1= c (0.3,0.2,0.4),
col2= c (0.45,0.67,0.612),
col3= c (0.35,0.92,0.84))
print (data)
print ( asin ( sqrt (data$col1)))
print ( asin ( sqrt (data$col3)))
|
Output:
Arcsine Transformation of Values Outside Range 0 to 1
Here if the values are not in the range of 0 to 1, we have to convert them in the range of 0 to 1. We can do this by dividing all the values to the maximum value in the data.
Syntax:
data_values / max(data)
Example: Transform in the range of values in the vector
R
data= c (23,45,32,2,34,21,22,67)
final=data/ max (data)
print (final)
print ( asin ( sqrt (final)))
|
Output:
Share your thoughts in the comments
Please Login to comment...