Given a word I need to find the decimal values of each letter in that word and store it in an array.
I used strtoi function to achieve this. But later found out below two functions which are supposed to give same output are giving different result. Can anyone explain why?
1st attempt
> strtoi("d",16L)
[1] 13
2nd attempt
> strtoi(charToRaw("d"),16L)
[1] 100
And what does 16L in the base of srtoi mean? I am fairly new to Dec, Hex, Oct representation of ASCII characters. So please share some information about it.
For illustration purposes only:
Since what you need to do can be done all in base R:
You can also do
as.integer()vsas.numeric()if you just need/want integers.