In this article, we will discuss about as.double() and is.double() functions in R Programming Language.
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()
# 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.
# 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