Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Convert String to Integer in R Programming – strtoi() Function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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:




# R program to illustrate
# strtoi function
  
# Initializing some string vector
x <- c("A", "B", "C")
y <- c("1", "2", "3")
  
# Calling strtoi() function
strtoi(x, 16L)
strtoi(y)

Output :

[1] 10 11 12
[1] 1 2 3

Example 2:




# R program to illustrate
# strtoi function
  
# Calling strtoi() function over
# some specified strings
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
My Personal Notes arrow_drop_up
Last Updated : 01 Jun, 2020
Like Article
Save Article
Similar Reads