Related Articles

Related Articles

Convert Character value to ASCII value in R Programming – charToRaw() Function
  • Last Updated : 01 Jun, 2020

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

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

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# charToRaw functiom
  
# 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

chevron_right


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 :