queryTable: Queries a form as a flat, two-dimensional table

View source: R/tableQuery.R

queryTableR Documentation

Queries a form as a flat, two-dimensional table

Description

Queries a form as a flat, two-dimensional table

Usage

queryTable(
  form,
  columns,
  ...,
  truncateStrings = TRUE,
  asTibble = FALSE,
  makeNames = TRUE,
  truncate.strings = truncateStrings,
  filter,
  window,
  sort
)

Arguments

form

form to query. This can be an object of type "tree", "class", or the id of the form as a character.

columns

select columns, see Details

...

If columns parameter is empty, the additional arguments are used as columns.

truncateStrings

TRUE if longer strings should be truncated to 128 characters

asTibble

default is FALSE to return a data.frame; TRUE if a tibble should be returned

makeNames

default is TRUE; FALSE if column names should not be checked and left as-is

truncate.strings

Deprecated: please use truncateStrings. TRUE if longer strings should be truncated to 128 characters

filter

an ActivityInfo formula string that limits the records returned

window

an integer vector in the format c(offset, limit) for the number of records to return.

sort

an ActivityInfo sort object that sorts the records returned

Details

To select columns, you can use

  • _id to get the record identifier,

  • _lastEditTime to get the (Unix) timestamp (in seconds),

  • the identifier of the form field (e.g. ck849fbaw4),

  • the field code (e.g. TOT_BNF),

  • the field label, enclosed in brackets if it contains spaces (e.g. [Type of school])

If you want to select a column in a reference form or in a parent form, use a period to create a path to the desired column. For example:

  • parent._id will select the identifier of the parent record and

  • Camp.Name will select the ‘Name’ field in the ‘Camp’ form.

References

Unix time, Wikipedia https://en.wikipedia.org/wiki/Unix_time

Examples

## Not run: 
queryTable("a2145507918", columns = c(
  id = "_id",
  name = "Name",
  campId = "camp",
  camp = "Camp.Name",
  governorate = "Camp.Governorate.Name",
  teachers = "teachers",
  students = "students",
  type = "[Type of School]"
))

## End(Not run)

bedatadriven/activityinfo-R documentation built on Dec. 21, 2024, 8:23 a.m.