To convert a String to an Integer in R, you can use the as.integer()
function.
In this example,
str
with a string value of "321"
.as.integer()
function to convert it to an integer and store the result in the variable number
.as.integer()
function converts the string to an integer.number
.str <- "321"
number <- as.integer(str)
print(paste("Integer value:", number))
[1] "Integer value: 321"
In this example,
str
with a string value of "654"
.as.integer()
function to convert it to an integer and store the result in the variable number
.as.integer()
function converts the string to an integer.number
.str <- "654"
number <- as.integer(str)
print(paste("Integer value:", number))
[1] "Integer value: 654"
In this tutorial, we learned How to Convert String to Integer in R language with well detailed examples.