Math calculation in assign method

Dear all,

1, is it possible to do matrix calculation in assign method, see below, the X.mat has already defined on server

datashield.assign.expr(opals[[1]], symbol = "xtx.mat", quote(t("X.mat")%*%"X.mat"))
Error in .appendError(n, e$message) : object 'n' not found

2, I am quite confued whether I should use “X.mat” or X.mat as the arguement? Could you explain the logic to pass the parameters of assign or aggregate methods.


Unless I am mistaking you are multiplying X.mat (a server variable) with nothing. Also, it is unclear whether X.mat exists on the server.

If you were to show us what your script is about, then we can help you better.

Best wishes,


Hi Hank,

It is quite tricky to do matrix calculations using the ds.assign or the ds.make functions because some symbols that you want to use might be blocked by the R parser.

However, in DataSHIELD we have a set of functions that can be used for different matrix calculations (e.g. transpose, multiplication, etc). Here is an example:

generate a vector of length 20 of uniformly distributed data

ds.rUnif(samp.size=20, min=-10, max=10, newobj=“randVector”)

check that the vector was created correctly



create a 4 by 5 matrix using the elements from the created random vector

ds.matrix(mdata=‘randVector’, nrows.scalar=4, ncols.scalar=5, newobj=“X.mat”)

check that the matrix was created correctly



create the transpose of X.mat (the transpose is a 5 by 4 matrix)


check that the matrix was created correctly



multiply X.mat by its transpose (the product is a 5 by 5 matrix)

ds.matrixMult(M1=“X.mat.Tr”, M2=“X.mat”, newobj=“”)

check that the matrix was created correctly