要将字符串转换为R中的ascii代码,我通常使用:
> strtoi(charToRaw("abcd"),16L)
[1] 97 98 99 100
Run Code Online (Sandbox Code Playgroud)
是否存在反函数,即
>myDesiredFunc(c(97 98 99 100))
[1] "abcd"
Run Code Online (Sandbox Code Playgroud)
谢谢.
我只是注意到R有一个intToUtf8和utf8ToInt函数做同样的事情.
> test<-utf8ToInt("Apples")
> test
[1] 65 112 112 108 101 115
> intToUtf8(test)
[1] "Apples"
Run Code Online (Sandbox Code Playgroud)
也:
rawToChar(as.raw(c(97,98,99,100)))
Run Code Online (Sandbox Code Playgroud)
?charToRaw在命令提示符下键入以获取更多信息.