ds.asNumeric {dsBaseClient}R Documentation

Turns a vector into numerical type

Description

This function is similar to R function as.numeric.

Usage

ds.asNumeric(x = NULL, newobj = NULL, datasources = NULL)

Arguments

x

a character, the name of the input vector.

newobj

the name of the new variable. If this argument is set to NULL, the name of the new variable is the name of the input variable with the suffixe '_num'.

datasources

a list of opal object(s) obtained after login in to opal servers; these objects hold also the data assign to R, as dataframe, from opal datasources. By default an internal function looks for 'opal' objects in the environment and sets this parameter.

Details

See details of the R function 'as.numeric'.

Value

nothing is returned to the client, the new object is stored on the server side.

Author(s)

Gaye, A.

See Also

ds.asFactor to turn a variable into a factor type.

ds.asList to contruct an object of type list.

ds.asCharacter to turn a variable into a character type.

ds.asMatrix to coerce an object into a matrix type.

Examples

{

  # load that contains the login details
  data(logindata)

  # login and assign specific variable(s)
  # (by default the assigned dataset is a dataframe named 'D')
  myvar <- list("GENDER")
  opals <- datashield.login(logins=logindata,assign=TRUE,variables=myvar)

  # turn the factor variable 'GENDER' into a character vector
  ds.asCharacter(x='D$GENDER', newobj="gender_ch")

  # now turn the newly created vector 'gender_ch' into a numeric
  ds.asNumeric(x='gender_ch', newobj="gender_nm")

  # clear the Datashield R sessions and logout
  datashield.logout(opals)

}

[Package dsBaseClient version 4.1.0 ]