I have large numbers which are as character, I want to convert them to a number but this gives different output then expected:
> as.numeric("716897400001401732323")
[1] 716897400001401716736
What is the reason that R could not interpret the full number correctly, and how could I solve this problem?
Sorry it it not really a duplicate because I am using the melt function to melt an array with dimension names big numbers.
test <- array(c(1,2,3,4,5,6,7,8), dim = c(2,2,2), dimnames = list(c("122323232323232312121","23232323232323212121"),
c("a","b"),
c("c", "d")))
> melt(test)
Var1 Var2 Var3 value
1 122323232323232317440 a c 1
2 23232323232323211264 a c 2
3 122323232323232317440 b c 3
4 23232323232323211264 b c 4
5 122323232323232317440 a d 5
6 23232323232323211264 a d 6
7 122323232323232317440 b d 7
8 23232323232323211264 b d 8
To make it more clear: the problem could be solved in two ways, first of all melt should hold it as character but I did not receive an answer to this question see: Melt a array and make numeric values character So I thought I will make the column type as character and the problem is solved, but then the problem occurs that the conversion from character to numeric does not work because the numbers are to large.
Hopefully the question does make more sense now