[R]文字列の16進数を10進数に変換する
as.integer関数とas.hexmode関数を組み合わせる。as.hexmode関数は引数に与えた文字列をhexmodeという種類の値に変換し、as.integer関数で整数に変換している。
> as.hexmode("f")
[1] "f"
> class(as.hexmode("f"))
[1] "hexmode"
> as.integer(as.hexmode("f"))
[1] 15
> as.integer(as.hexmode("ff"))
[1] 255
> as.integer(as.hexmode("ff")) + 1
[1] 256
« [R]文字列から各文字の文字コードを得る | トップページ | [R]任意の進数表記の文字列を任意の進数に変換する »
「R(文字と文字列)」カテゴリの記事
- [R]同じ文字列を繰り返した文字列を作成する(2026.02.02)
- [R]文字列が数値に変換できるかどうか判定する(2025.12.31)
- [R]文字列の長さを得る(2025.12.30)
- [R]空白を追加した指定の長さの文字列を得る(2025.12.26)
- [R]文字列型ベクトルの要素を連結して文字列を作る(2025.12.17)
« [R]文字列から各文字の文字コードを得る | トップページ | [R]任意の進数表記の文字列を任意の進数に変換する »

コメント