Square Root in R (2 Examples)
This page shows how to compute the square root with the sqrt() function in the R programming language.
Example 1: Basic Application of sqrt Function
sqrt(5) # Apply sqrt function in R # 2.236068 |
sqrt(5) # Apply sqrt function in R # 2.236068
Example 2: Compute Square Root of All Vector Elements
vec <- c(5, 3, 1, 9, 4) # Create example vector sqrt(vec) # Apply sqrt to vector # 2.236068 1.732051 1.000000 3.000000 2.000000 |
vec <- c(5, 3, 1, 9, 4) # Create example vector sqrt(vec) # Apply sqrt to vector # 2.236068 1.732051 1.000000 3.000000 2.000000