Convert Character value to ASCII value in R Programming – charToRaw() Function
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 alphabetsx <- charToRaw("a")y <- charToRaw("A")z <- charToRaw("ab")# Getting the corresponding ASCII valuexyz |
Output :
[1] 61 [1] 41 [1] 61 62
Example 2:
Python3
# R program to illustrate# charToRaw function# Initializing some stringsa <- "Geeks"b <- "GFG is a CS Portal"# Calling charToRaw() function# over above stringsc <- charToRaw(a)d <- charToRaw(b)# Getting the ASCII values of the above# specified stringscd |
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


