R sqrt() function is used to find the square root of a number.
In this tutorial, we will learn how to use
sqrt() function to compute the square root of given value.
The syntax of
sqrt() function to compute square root of
Returns the square root of
x can be a numeric or complex vector or array.
In the following program, we will find the square root of a number
x <- 16 result <- sqrt(x) cat("The sqaure root of", x, "is :", result)
The sqaure root of 16 is : 4
Now, let us take an array of numbers, and find their square roots.
x <- array(c(1, 16, 9), dim=c(3,1)) result <- sqrt(x) cat("The sqaure root of array [", x, "] is :", result)
The sqaure root of array [ 1 16 9 ] is : 1 4 3
In this R Tutorial, we learned how to find the square root of a numeric value using
sqrt() function, with the help of examples.