Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting ascii number to strings in R

Tags:

r

To convert strings to ascii code in R, I typically use:

> strtoi(charToRaw("abcd"),16L)
[1] 97 98 99 100

Is there a function to do the inverse, i.e.

>myDesiredFunc(c(97 98 99 100)) 
[1] "abcd"

Thanks.

like image 766
uday Avatar asked Apr 17 '14 02:04

uday


1 Answers

I just noticed that R has a intToUtf8 and utf8ToInt functions that does the same thing.

> test<-utf8ToInt("Apples")
> test
[1]  65 112 112 108 101 115
> intToUtf8(test)
[1] "Apples"
like image 94
uday Avatar answered Oct 07 '22 20:10

uday