Reputation: 2367
In C/C++ we just do nX = cX - " "
to obtain integer nX
from character cX
.
How do we do it in R ?
Upvotes: 1
Views: 1125
Reputation: 3882
charToRaw
returns a vector with the integer code, without taking into account any declared encoding.
See: ??charToRaw
for more help and related functions.
Example:
charToRaw("A")
#[1] 41
charToRaw("AB")
# [1] 41 42
is.vector(charToRaw("AB"))
# TRUE
Upvotes: 3