as.integer()
function in R Language is used to convert a character object to integer object.
Syntax: as.integer(x)
Parameters:
x: Character Object
Example 1:
# R program to convert a character object # to an integer object # Calling as.integer() function as.integer("4") as.integer("1.6") as.integer("-3.2") as.integer("0x400")
Output:
[1] 4 [1] 1 [1] -3 [1] 1024
Example 2:
# R program to convert a character object # to an integer object # Creating a vector x <- c(1, 2, 3, 4, 5) # Check if the vector is an integer is.integer(x) # Convert to integer x1 <- as.integer(x) x1 # Calling is.integer() function is.integer(x1)
Output:
[1] FALSE [1] 1 2 3 4 5 [1] TRUE
Australia
UK
UAE
Singapore
Canada
New
Zealand
Malaysia
USA
India
South
Africa
Ireland
Saudi
Arab
Qatar
Kuwait
Hongkong
Copyright 2016-2023 www.programmingshark.com - All Rights Reserved.
Disclaimer : Any type of help and guidance service given by us is just for reference purpose. We never ask any of our clients to submit our solution guide as it is, anywhere.