Import a Viva Insights Query from a .csv file, with variable classifications optimised for other functions in the package.
Usage
import_query(
  x,
  pid = NULL,
  dateid = NULL,
  date_format = "%m/%d/%Y",
  convert_date = TRUE,
  encoding = "UTF-8"
)Arguments
- x
 String containing the path to the Viva Insights query to be imported. The input file must be a .csv file, and the file extension must be explicitly entered, e.g.
"/files/standard query.csv"- pid
 String specifying the unique person or individual identifier variable.
import_queryrenames this toPersonIdso that this is compatible with other functions in the package. Defaults toNULL, where no action is taken.- dateid
 String specifying the date variable.
import_queryrenames this toMetricDateso that this is compatible with other functions in the package. Defaults toNULL, where no action is taken.- date_format
 String specifying the date format for converting any variable that may be a date to a Date variable. Defaults to
"%m/%d/%Y".- convert_date
 Logical. Defaults to
TRUE. When set toTRUE, any variable that matches true withis_date_format()gets converted to a Date variable. When set toFALSE, this step is skipped.- encoding
 String to specify encoding to be used within
data.table::fread(). Seedata.table::fread()documentation for more information. Defaults to'UTF-8'.
Details
import_query() uses data.table::fread() to import .csv files for
speed, and by default stringsAsFactors is set to FALSE. A data frame is
returned by the function (not a data.table). Column names are automatically
cleaned, replacing spaces and special characters with underscores.
See also
Other Import and Export:
copy_df(),
create_dt(),
export(),
prep_query()
