Skip to content
Related Articles

Related Articles

Improve Article

Convert Character value to ASCII value in R Programming – charToRaw() Function

  • Last Updated : 02 Mar, 2021

charToRaw() function in R Language is used to convert the given character to their corresponding ASCII value or “raw” objects.
 

Syntax: charToRaw(x)
Parameters: 
x: Given characters to be converted 
 

Example 1: 
 

Python3




# R program to illustrate
# charToRaw function
 
# Calling charToRaw() function over
# some alphabets
x <- charToRaw("a")
y <- charToRaw("A")
z <- charToRaw("ab")
 
# Getting the corresponding ASCII value
x
y
z

Output : 
 



[1] 61
[1] 41
[1] 61 62

Example 2: 
 

Python3




# R program to illustrate
# charToRaw function
 
# Initializing some strings
a <- "Geeks"
b <- "GFG is a CS Portal"
 
# Calling charToRaw() function
# over above strings
c <- charToRaw(a)
d <- charToRaw(b)
 
# Getting the ASCII values of the above
# specified strings
c
d

Output: 
 

[1] 47 65 65 6b 73
[1] 47 46 47 20 69 73 20 61 20 43 53 20 50 6f 72 74 61 6c

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :