sb_insert_event()
imports a data frame into a Smartabase event form using
the Smartabase API. It requires the user to input a data frame, a valid
Smartabase event form name, url and credentials.
For more details see the help vignette:
vignette("exporting-data")
Usage
sb_insert_event(
df,
form,
url,
username,
password,
...,
option = sb_insert_event_option()
)
Arguments
- df
Data to be imported to Smartabase
- form
Name of Smartabase event form
- url
Smartabase url e.g. "example.smartabase.com/site"
- username
Smartabase username
- password
Smartabase password
- ...
These dots are for future extensions and must be empty
- option
More options accessible via
sb_insert_event_option()
object
start_date / end_date / start_time / end_time columns
When uploading data to Smartabase, the API requires metadata about when the
event started and stopped. sb_insert_event()
will first search for any
columns in the data named "start_time" and "end_time", which must have
values in h:mm AM or h:mm PM format.
If those columns do not exist, start_time
and end_time
will be set to
the current time and one hour after the current time, respectively.
Likewise, sb_insert_event()
will also search for any columns named
"start_date" or "end_date", which must have values formatted as dd/mm/YYYY.
If those columns do not exist, both start_date
and end_date
will be set
to the current date (unless the difference between start_time
and
end_time
spans midnight, in which case the end_date
will be set to the
current date plus one day).
Options
There are also a range extra options than can be supplied to the option
argument, including options for setting a different ID column and supplying
the names of table fields, among others. In order to reduce argument clutter
in sb_insert_event()
, all options must be generated by the
sb_insert_event_option()
function. Please see sb_insert_event_option()
for more details.
Examples
if (FALSE) { # \dontrun{
example_df <- dplyr::tibble(
user_id = c(31813, 31819),
`Body Weight pre training` = round(runif(2, 82, 92), 0),
`Body Weight post training` = round(runif(2, 82, 92), 0),
`Urine Colour` = round(runif(2, 1, 8), 0)
)
sb_insert_event(
df = example_df,
form = "Hydration",
url = "example.smartabase.com/site",
username = "john.smith",
password = "example_password"
)
} # }