get_sensor_data: This function extracts data from the database.

Description Usage Arguments Value See Also Examples

View source: R/extracting.R

Description

This function extracts data from the database.

Usage

1
2
3
get_sensor_data(tablename, do_aggregate = FALSE, clean_first = FALSE,
  aggregation_unit = "15 min", xtravars = "all", summarize_vars = NULL,
  grouping_vars = c("subjectid", "sessionid"))

Arguments

tablename

What is the name of the table (as a string).

do_aggregate

should the data be aggregated (TRUE/FALSE).

clean_first

should the data go through the table-specific cleaning procedure first.

aggregation_unit

what time unit should be used for aggregation. This should be a string with a number followed by min, hour, day. Plural is OK (e.g., 'days')

xtravars

what extra variables should be extracted when grabbing raw data. Should be NULL if aggregating! Note that this should be a vector of variable names or the word "all" to get all variables.

summarize_vars

What variables will be summarized. This should be a vector of variable names – variables should be numeric.

grouping_vars

What variables will be used for aggregation (these are the keys)

Value

user.

See Also

Other postgresql functions: add_tables_db, agg_unit_ok, aggregate_data, already_uploaded, backup_database, column_exists, column_types, create_database, delete_data, get_column_names, get_connection, get_filenames_forSubject, get_filenames, get_row_count, get_subjectid, kill_pg_connections, list_tables, process_hexoskin, restore_database, table_exists, upload_postgres, valid_connection

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
res<-get_sensor_data("hxi", clean_first=FALSE, xtravars="datetime") 
res<-get_sensor_data("hxi", xtravars=c("datetime", "subjectid"))  

res<-get_sensor_data("gps")
res<-get_sensor_data(tablename= "hxi", 
                     do_aggregate=TRUE, 
                     xtravars= NULL,
                      aggregation_unit="2 hours",
                     grouping_vars = c("subjectid", "sessionid"),
                     summarize_vars=c("cadence", "breathing_rate"))

# this will give you average lat, long (centroid) of each subject/session
res<-get_sensor_data("gps",
                     do_aggregate=TRUE, 
                     xtravars= NULL,
                     aggregation_unit="complete",
                     grouping_vars = c( "subjectid", "sessionid"),
                     summarize_vars=c("latitude", "longitude"))
# gives error, check xtravars
res<-get_sensor_data("hxi", xtravars=c("datetime", "asdfjasf")) #gives error

# gives error check grouping vars
res<-get_sensor_data("hxi", 
                     do_aggregate=TRUE, 
                     xtravars= NULL,
                     aggregation_unit="2 hours",
                     grouping_vars = c("datetime", "subjectid", "asdlfjsdlfj"),
                     summarize_vars=c("cadence", "breathing_rate"))
                     
res<-get_sensor_data("mpm",
   clean_first = TRUE,
   do_aggregate=TRUE,
   xtravars  = NULL,
   aggregation_unit="1 hour",
   grouping_vars = c( "subjectid", "sessionid"),
   summarize_vars = c("temperature", "rh", "flow"))
   
   

zevross-spatial/rpackage-sensorDataImport documentation built on Aug. 16, 2019, 4:53 p.m.