ds.asDataMatrix {dsBaseClient}R Documentation

ds.asDataMatrix calling assign function asDataMatrixDS


Coerces an R object into a matrix maintaining original class for all columns in data.frames


ds.asDataMatrix(x.name = NULL, newobj = NULL, datasources = NULL)



the name of the input object to be coerced to a data.matrix. Must be specified in inverted commas eg x.name="name.of.object"


the name of the new output variable specified in inverted commas. If this argument is set to NULL, the name of the new variable is defaulted to <x.name>.mat


specifies the particular opal object(s) to use. If the <datasources> argument is not specified the default set of opals will be used. The default opals are called default.opals and the default can be set using the function ds.setDefaultOpals. If an explicit <datasources> argument is to be set, it should be specified without inverted commas: e.g. datasources=opals.em or datasources=default.opals. If you wish to apply the function solely to e.g. the second opal server in a set of three, the argument can be specified as: e.g. datasources=opals.em[2]. If you wish to specify the first and third opal servers in a set you specify: e.g. datasources=opals.em[c(1,3)]


This function is based on the native R function data.matrix If applied to a data.frame, the native R function as.matrix converts all columns into character class. In contrast, if applied to a data.frame the native R function data.matrix converts the data.frame to a matrix but maintains all data columns in their original class


the object specified by the <newobj> argument (or by default <x.name>.mat if the <newobj> argument is NULL) which is written to the serverside. In addition, two validity messages are returned indicating whether <newobj> has been created in each data source and if so whether it is in a valid form. If its form is not valid in at least one study there may be a studysideMessage that can explain the error in creating the full output object. As well as appearing on the screen at run time,if you wish to see the relevant studysideMessages at a later date you can use the ds.message function. If you type ds.message(<newobj>) it will print out the relevant studysideMessage from any datasource in which there was an error in creating <newobj> and a studysideMessage was saved. If there was no error and <newobj> was created without problems no studysideMessage will have been saved and ds.message(<newobj>) will return the message: "ALL OK: there are no studysideMessage(s) on this datasource".


Paul Burton, for DataSHIELD Development Team

[Package dsBaseClient version 5.0.0 ]