我發現在fBasics
包中有函數.hex.to.dec
。在R中將十六進制轉換爲十進制
當我做.hex.to.dec(a)
,它的工作原理。
我有一個數據幀與由這樣的值的列samp_column
:
a373, 115c6, a373, 115c6, 176b3
當我做.hex.to.dec(samp_column)
,我得到這個錯誤:
"Error in nchar(b) : 'nchar()' requires a character vector"
當我做.hex.to.dec(as.character(samp_column))
,我得到這個錯誤:
"Error in rep(base.out, 1 + ceiling(log(max(number), base = base.out))) : invalid 'times' argument"
什麼是be這樣做的方式?
'strtoi'將執行此操作。或者很長的路要走:'Rutils :: as.character.binmode',然後用'as.numeric'將字符轉換爲數字:-) –
請閱讀[如何格式化您的問題](http://stackoverflow.com/editing-help),然後介紹包含數據的[如何製作可重複使用的示例](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)。 – Thomas
謝謝卡爾!出於某種原因,這個功能沒有出現在我的Google搜索中,但它似乎工作得很好。 :)乾杯! –