load_SL_tibble {studentlife} | R Documentation |
load_SL_tibble
Description
Import a chosen StudentLife table as
a tibble. Leave schema
and table
unspecified to choose interactively via a
menu. This function is only intended for use
with the studentlife dataset in it's original
format, with the original directory structure.
See the examples below for the recommended alternative approach
to loading tables when the RData format is used.
Usage
load_SL_tibble(
schema,
table,
location = ".",
time_options = c("interval", "timestamp", "dateonly", "dateless"),
vars,
csv_nrows,
datafolder = "dataset",
uid_range = getOption("SL_uids")
)
Arguments
schema |
A character string. The menu 1 choice. Leave blank to choose interactively. |
table |
A character string. The menu 2 choice. Leave blank to choose interactively. |
location |
The path to a copy of the StudentLife dataset. |
time_options |
A character vector specifying which table types (out of "interval", "timestamp", "dateonly" and "dateless") to include in the menu. This allows you to restrict menu options according to the amount of date-time information present in the data. The default includes all data. Note this parameter only has an effect when used with the interactive menu. |
vars |
Character vector of variable
names to import for all students. Leave
blank and this will be chosen interactively
if necesssary. If |
csv_nrows |
An integer specifying the number of rows to read per student if the target is a csv. The largest files in StudentLife are csv files, so this allows code testing with less overhead. |
datafolder |
Specifies the subfolder of |
uid_range |
An integer vector. The range of uids in the StudentLife study. |
Value
An object of class SL_tibble
is returned. These inherit
properties from class tibble
and
class data.frame
.
Depending on the date-time information available, the object
may also be a timestamp_SL_tibble
,
interval_SL_tibble
or
dateonly_SL_tibble
(which are all
subclasses of SL_tibble
).
Examples
## Example that uses RData format to efficiently
## download and load tables, as an alternative
## to using this function.
## Not run:
d <- tempdir()
download_studentlife(location = d, url = "rdata")
# Choose the schema and table from the list SL_tables:
SL_tables
# Example with activity table from sensing schema
schema <- "sensing"
table <- "activity"
act <- readRDS(paste0(d, "/dataset_rds/", schema, "/", table, ".Rds"))
act
## End(Not run)
## Example that uses the studentlife dataset in
## its original format.
# Use url = "dartmouth" for the full original dataset
d <- tempdir()
download_studentlife(location = d, url = "testdata")
## Not run:
## With menu
load_SL_tibble(location = d)
## End(Not run)
## Without menu
SL_tables
PAM <- load_SL_tibble(schema = "EMA", table = "PAM", location = d)
## Load less data for testing with less overhead
act <- load_SL_tibble(schema = "sensing", table = "activity",
location = d, csv_nrows = 10)
## Not run:
## Browse all tables with timestamps (non-interval)
load_SL_tibble(location = d, time_options = "timestamp")
## Browse all tables with intervals
load_SL_tibble(location = d, time_options = "interval")
## Browse all dateless tables
load_SL_tibble(location = d, time_options = "dateless")
## End(Not run)