Learn R Programming

places (version 0.1.1)

get_home: Predict which cluster is an individual's home.

Description

Predict which cluster is an individual's home.

Usage

get_home(
  df1,
  df2,
  home.start = "00:00:00",
  home.end = "06:00:00",
  filt = TRUE,
  max.distance = 150
)

Arguments

df1

A dataframe of GPS coordinates as described below.

df2

A dataframe with named clusters (most likely the dataframe that is returned after running reduce_multi OR the places dataframe that is returned after running get_clusters).

home.start

A character vector HH:MM:SS which represents the start time that most individuals will be asleep by.

home.end

A character vector HH:MM:SS which represent the start time that most individual may start to wake up by.

filt

A logical T or F if the GPS data should be filtered between home.start and home.end. The default is T.

max.distance

An integer in meters. It is the maximum distance in meters a cluster can be from the home location to be labelled as "home". The defaults is 150 m.

Value

Returns a list of dataframes. COUNT is a dataframe that count how many times an individual was at a clusters HOME is a dataframe with clusters labelled as "Home", "Other", "In Transit"

Dataframe Requirements

The dataframe needs to have the following named columns:

  • user_id = participant id

  • lat = latitude coordinates

  • lon = longitude coordinates

  • start_time = GPS coordinates as POSIXct. Assumes POSIXct variable has been created using UTC timezone.

  • tz_olson_id = local timezone (e.g., EST, America/New_York) as character vector.

See Also

get_clusters to cluster GPS coordinates into places.

get_places to label each cluster's place type as identified by Google Places API

Examples

Run this code
# NOT RUN {
## Assume you have run get_clusters() on the dataset "places_gps"
# }
# NOT RUN {
home <- get_home(places_gps, clusters[[1]], home.start = "21:30:00", home.end = "09:30:00")
# }

Run the code above in your browser using DataLab