Learn R Programming

Causata (version 4.2-0)

Connect: Connect to Causata and extract data.

Description

These functions open a connection to a Causata server, extract data, and close the connection.

Usage

Connect(sql.server.host, sql.server.port, sql.username, sql.password, group=NULL, verbose=FALSE) "GetData"(conn, query, ...)
"GetCausataData"(conn, query, dependent.variable, ...)
"GetRawData"(conn, query, ...)
"GetQuery"(this, ...)
"GetNames"(this, kind, ...)
"Close"(conn, ...)

Arguments

sql.server.host
The SQL server hostname. Contact your Causata Engagement Manager for the correct value.
sql.server.port
The SQL server port. Contact your Causata Engagement Manager for the correct value.
sql.username
Your Causata username. Contact your Causata Engagement Manager for the correct value.
sql.password
Your Causata password. Contact your Causata Engagement Manager for the correct value.
group
Configuration data from the group provided will be loaded from the configuration file. See LoadCausataConfig. If the same parameter is provided in the configuration file and the function argument then the function argument will take precedence.
verbose
If TRUE then the connection information will be printed to the screen.
conn
A connection object from Connect.
query
A query object from Query.
this
A CausataData object.
kind
The kind of variable name to return, valid values are 'display' and 'system'.
dependent.variable
...
Unused arguments for other methods.

Value

Connect returns an object of class Connect. GetData and GetRawData return data frames, while GetCausataData returns an object of class CausataData. Finally, GetNames returns a character vector of variable names.

Details

  • Connect opens a SQL connection to a Causata server using functions from the RMySQL package.
  • GetData executes the provided query and returns data in a data frame.
  • GetCausataData executes the provided query and returns data in a CausataData object.
  • GetRawData returns unaltered data from the lower level query commands.
  • Close simply closes a database connection.

GetData and GetRawData return data encoded in different formats using the Causata SQL interface. GetData is consistent with Causata data exported into CSV files, so it should generally be used instead of GetRawData.

The default behavior when using SQL queries of Causata within R is that boolean data in Causata is returned as numeric (1=TRUE, 0=FALSE), and text data is returned as characters. The other functions, GetData and GetCausataData, convert boolean data to factors with level names "true" and "false", and return character data as factors. This is the same format as data exported from Causata to CSV files.

GetNames is used to return the system names or display names for Causata variables.

See Also

Connect, Query, CausataData, RMySQL, LoadCausataConfig.

Examples

Run this code
# This command requires a connection to a Causata server
# the example below is for illustration only
## Not run: 
# conn <- Connect(hostname="example.causata.com", username="exampleuser", 
#   password="examplepassword")
# data <- GetData(conn, Query())
# Close(conn)## End(Not run)

Run the code above in your browser using DataLab