Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor
assign_variables
assign_variables

Expand
titleUnsure of how to make this compatible with new login method...

Assign individual variables on login

Users can specify individual variables to assign to the server-side R session. It is best practice to first create a list of the Opal variables you want to analyse.

  • The example below creates a new variable myvar that lists the Opal variables required for analysis: LAB_HDL and GENDER
  • The variables argument in the function datashield.login uses myvar, which then will call only this list.
Code Block
languagexml
myvar <- list('LAB_HDL', 'GENDER')
connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D", variables=myvar)


Code Block
languagexml
themeRDark
Logging into the collaborating servers
  Logged in all servers [================================================================] 100% / 4s

Assigning table data...
  Assigned all tables [==================================================================] 100% / 7s

Variables assigned:
study1 -- LAB_HDL, GENDER
study2 -- LAB_HDL, GENDER


Tip
titleThe format of assigned data frames

Assigned data are kept in a data frame (table) named D by default. Each row of the data frame are the individual records and each column is a separate variable.

  • The example below uses the argument symbol in the datashield.login function to change the name of the data frame from D to mytable
Code Block
languagexml
myvar <- list('LAB_HDL', 'GENDER')
connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol='mytable', variables=myvar)


Code Block
languagexml
themeRDark
Logging into the collaborating servers
  Logged in all servers [================================================================] 100% / 4s

Assigning table data...
  Assigned all tables [==================================================================] 100% / 6s

Variables assigned:
study1 -- LAB_HDL, GENDER
study2 -- LAB_HDL, GENDER



Conclusion

The other parts in this DataSHIELD tutorial series are:

...