Trusted answers to developer questions

harris910

The ** sqrt() function** in R is used to calculate the

Figure 1 shows the mathematical representation of the `sqrt()`

function.

```
sqrt(number)
```

`sqrt()`

requires a non-negative number as a parameter.

`sqrt()`

returns the square root of the number sent as a parameter.

If a negative number is sent as a parameter, then

`sqrt()`

returns`NaN`

, along with a`warning`

message.

#Perfect square root a <- sqrt(4); print(paste0("sqrt(4): ", a)) b <- sqrt(0); print(paste0("sqrt(0): ", b)) #simple number c <- sqrt(5); print(paste0("sqrt(5): ", c)) d <- sqrt(4.5); print(paste0("sqrt(4.5): ", d)) #negative number e <- sqrt(-2); print(paste0("sqrt(-2): ", e))

RELATED TAGS

r

math

squareroot

communitycreator

CONTRIBUTOR

harris910

RELATED COURSES

View all Courses

Keep Exploring

Related Courses