strtoi()
function in R Language is used to convert the specified string to integers.
Syntax: strtoi(x, base=0L)
Parameters:
x: character vector
base: integer between 2 and 36 inclusive, default is 0
Example 1:
x < - c( "A" , "B" , "C" )
y < - c( "1" , "2" , "3" )
strtoi(x, 16L )
strtoi(y)
|
Output :
[1] 10 11 12
[1] 1 2 3
Example 2:
strtoi(c( "0xff" , "023" , "567" ))
strtoi(c( "ffff" , "FFFF" ), 16L )
strtoi(c( "246" , "135" ), 8L )
|
Output:
[1] 255 19 567
[1] 65535 65535
[1] 166 93