I have to work with big.matrix objects and I can’t compute some functions. Let's consider the following big.matrix:
# create big.matrix object
x <- as.big.matrix(
matrix( sample(1:10, 20, replace=TRUE), 5, 4,
dimnames=list( NULL, c("a", "b", "c", "d")) ) )
> x
An object of class "big.matrix"
Slot "address":
<pointer: 0x00000000141beee0>
The corresponding matrix object is:
# create matrix object
x2<-x[,]
> x2
a b c d
[1,] 6 9 5 3
[2,] 3 6 10 8
[3,] 7 1 2 8
[4,] 7 8 4 10
[5,] 6 3 6 4
If I compute this operations with the matrix object, it works:
sqrt(slam::col_sums(x2*x2))
> sqrt(slam::col_sums(x2*x2))
a b c d
13.37909 13.82027 13.45362 15.90597
While if I use the big.matrix object (in fact what I have to use), it doesn’t work:
sqrt(biganalytics::colsum(x*x))
The problems are 2 : the * operation (to create the square of each element of the matrix), which produces the error:
Error in x * x : non-numeric argument transformed into binary operator
and the sqrt function, which produces the error :
Error in sqrt(x) : non-numeric argument to mathematical function.
How can I compute this operations with big.matrix objects?