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

ds.ls()

ds.class(“randVector”)

ds.length(“randVector”)

# 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

ds.ls()

ds.class(“X.mat”)

ds.dim(“X.mat”)

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

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

# check that the matrix was created correctly

ds.ls()

ds.class(“X.mat.Tr”)

ds.dim(“X.mat.Tr”)

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

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

# check that the matrix was created correctly

ds.ls()

ds.class(“X.mat.prod”)

ds.dim(“X.mat.prod”)