-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
117 lines (79 loc) · 4.42 KB
/
README.Rmd
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
output:
github_document
nocite: |
@Klinker:2014, @Klinker:2015, @Pizarro:2016, @Stewart:2017
bibliography: references.bib
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# PALMSplus for R
<!--[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/TheTS/palmsplusr?branch=master&svg=true)](https://ci.appveyor.com/project/TheTS/palmsplusr)-->
<!--[![Travis-CI Build Status](https://travis-ci.org/TheTS/palmsplusr.svg?branch=master)](https://travis-ci.org/TheTS/palmsplusr) -->
<!--[![codecov](https://codecov.io/gh/TheTS/actigraph.sleepr/branch/master/graph/badge.svg)](https://codecov.io/gh/TheTS/actigraph.sleepr)-->
[![Project Status](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![Version](https://img.shields.io/badge/Package%20version-0.1.0-green.svg)](commits/master)
[![Last Change](https://img.shields.io/badge/Last%20change-`r gsub('-', '--', Sys.Date())`-yellowgreen.svg)](/commits/master)
## Overview
**palmsplusr** is an extension to the *Personal Activity Location Measurement System* ([PALMS](https://ucsd-palms-project.wikispaces.com/)). This R package provides a customisable platform to combine PALMS data with other sources of information (e.g., shapefiles or csv files). This enables physical activity researchers to answer higher-level questions, such as:
* How much time is spent in parks?
* How much MVPA is accumulated in parks?
* What proportion of sedentary time is accumulated during vehicular travel?
* What is the average distance of home-to-school trips?
* How much MVPA is accumulated inside the schoolyard during school time?
* What proportion of commuters trip chain different travel modes (e.g., walk-bus-walk)
* What is the average speed of bicycle trips during peak travel times?
The PALMS data are combined with other input files to build the palmsplus [simple features](https://github.com/r-spatial/sf) data frame. This can then be summarised two ways:
1. `days` provides a breakdown of information per day, per person (e.g., time spent in greenspace)
2. `trajectories` builds individual trips, and provides trip-level summaries (e.g., MVPA during the work commute). This can then be processed into multimodal trips if desired.
The user is able to specify how each data source is combined. This is done by creating `field` tables using highly customisable formulas.
![Palms Workflow](http://i.imgur.com/aSzlC3E.png)
## Brief Example
This example demonstrates the most basic implementation with one participant:
```{r message=FALSE, warning=FALSE}
library(palmsplusr)
palms <- read_palms("F:/data/csv/one_participant.csv")
palms_load_defaults(palms_epoch(palms))
```
The `palms_load_defaults()` function automatically populates the field tables with basic formulas. Each of these fields will be calculated and added to the `palmsplus` dataset. The default `palmsplus_fields` table looks like:
```{r}
palmsplus_fields
```
There are four other field tables that can be customized by the user:
* `palmsplus_domains` is used to specify aggregation domains for `days`
* `trajectory_fields` is used to specify fields for `trajectories`
* `trajectory_locations` is used to specify trip start and end locations (e.g., home-school trip)
* `multimodal_fields` is used to specify the fields summarized in `multimodal`
Building datasets using these field tables is as simple as:
```{r message=FALSE, warning=FALSE}
# Building palmsplus
palmsplus <- palms_build_palmsplus(palms)
# Building days
days <- palms_build_days(palmsplus)
# Building trajectories
trajectories <- palms_build_trajectories(palmsplus)
# Building multimodal trajectories
multimodal <- palms_build_multimodal(trajectories, 200, 10)
```
Results can easily be saved to csv or shapefile:
```{r eval=FALSE}
write_csv(days, "days.csv")
st_write(trajectories, "trajecories.shp")
```
## Installation
The easiest way to install **palmsplusr** is using devtools:
```{r, eval = FALSE}
library("devtools")
install_github("TheTS/palmsplusr")
```
## Documentation and Examples
For further information and extensive examples, please see the [GitHub documentation](http://thets.github.io/palmsplusr/)
## Notes
This project is based on the [palmsplus](https://github.com/bsnizek/palmsplus) project originally written in PostgreSQL and PostGIS by [Bernhard Snizek](http://www.snizek.com).
## References