GeeksforGeeks App
Open App
Browser
Continue

# as.double() and is.double() Functions in R

## as.double() Method in R

as.double is used to  convert an integer to double.

Syntax: as.double(input_values)

Both will take values as input.

Example: In this example, we will a vector with 5 elements and convert to double using as.double()

## R

 `# create vector``vector1=``c``(2,3,4,5,6)`` ` `# display``print``(vector1)`` ` `# convert to double``result= ``as.double``(vector1)`` ` `# display``print``(vector1)`

Output:

```[1] 2 3 4 5 6
[1] 2 3 4 5 6```

## is.double() methods in R

is.double() is used to test an data object has the double class.

Syntax: is.double(input_values)

Example: In this example, we will a vector with 5 elements and convert to double using as.double() and check they are double or not using is.double()

It will return TRUE, if it is double otherwise it will return FALSE.

## R

 `# create vector``vector1=``c``(2,3,4,5,6)`` ` `# convert to double``result= ``as.double``(vector1)`` ` `# check double or not``print``(``is.double``(result))`

Output:

`[1] TRUE`
My Personal Notes arrow_drop_up