Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (18.1%) to scientific vocabulary
Keywords
mobile-sensing
r
Last synced: 11 months ago
·
JSON representation
Repository
Mirror of the mpathsenser package from Gitlab.
Basic Info
- Host: GitHub
- Owner: koenniem
- License: gpl-3.0
- Language: R
- Default Branch: master
- Homepage: https://gitlab.kuleuven.be/ppw-okpiv/researchers/u0134047/mpathsenser
- Size: 6.93 MB
Statistics
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 7
Topics
mobile-sensing
r
Created over 3 years ago
· Last pushed over 1 year ago
Metadata Files
Readme
Changelog
Contributing
License
Code of conduct
Codemeta
README.Rmd
---
output: github_document
---
```{r, include = FALSE, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/",
out.width = "100%"
)
options(tibble.print_min = 5, tibble.print_max = 5)
library(mpathsenser)
```
# mpathsenser
[](https://cran.r-project.org/package=mpathsenser)
[](https://www.repostatus.org/#active)
## Installing the package
You can install the latest version of mpathsenser from CRAN:
```{r, eval = FALSE}
install.packages("mpathsenser")
```
Alternatively, you can install the development version from my Gitlab repo. First, make sure you have [Rtools](https://cran.r-project.org/bin/windows/Rtools/) (Windows, Linux) or XCode installed. For XCode, register as an [Apple Developer](https://developer.apple.com/) (don't worry, it's free) and then run `xcode-select --install` in a terminal. Then, run the following code in R:
```{r, eval = FALSE}
devtools::install_git("https://gitlab.kuleuven.be/ppw-okpiv/researchers/u0134047/mpathsenser")
```
## Importing files
Specify a path variable to wherever you put the JSON files. Make sure to use `/` and not a backslash.
```{r, eval = FALSE}
path <- "~/Mobile Sensing Study/Data"
```
```{r, include = FALSE, echo = FALSE}
# Get the temp folder
tempdir <- tempdir()
tempdir <- file.path(tempdir, "readme")
if (dir.exists(tempdir)) {
unlink(tempdir, recursive = TRUE, force = TRUE)
}
dir.create(tempdir)
# Get a handle to the data files
path <- system.file("extdata", "example", package = "mpathsenser")
# Get a list of all the files that are to be copied
copy_list <- list.files(path, "carp-data", full.names = TRUE)
# Copy all data
invisible(file.copy(
from = copy_list,
to = tempdir,
overwrite = TRUE,
copy.mode = FALSE
))
path <- tempdir
```
If you haven't done so, unzip all files.
```{r}
unzip_data(path = path)
```
In m-Path Sense, data is written to JSON files as it comes in. In the JSON file format, every file starts with `[` and ends with `]`. If the app is killed, JSON files may not be properly closed and hence cannot be read by JSON parsers. So, we must first test if all files are in a valid JSON format and fix those that are not.
```{r}
# Test JSONs for problems. Output is a character vector containing bad files (if any).
to_fix <- test_jsons(path = path)
# Fix JSON files if there are any.
# Note that test_jsons() returns the full path names, so a path directory is not necessary.
if (length(to_fix) > 0) {
fix_jsons(path = NULL, files = to_fix)
}
```
To import data, first create a database.
```{r}
db <- create_db(path = path, db_name = "some_db.db")
```
Then, call `import()` to start reading in the files.
```{r}
import(path = path, db = db)
```
If everything went correctly, there should be a message that all files were successfully written to the database. Otherwise `import()` return a character vector containing the files that failed to be imported. Note that files only need to be imported once, and that new files can be added to the database by calling `import()` again using the same database. Files that were processed previously will be skipped.
## Extracting data from the database
Once files are imported, you can establish a database connection with `open_db()`. Don't forget to save it to a variable!
```{r, eval = FALSE}
db <- open_db(
path = path,
db_name = "some_db.db"
)
```
To find out which participants are in the database (or rather their participant numbers):
```{r}
get_participants(db)
```
We can also check what device they are using (which can be found in the Device table of the database).
```{r}
device_info(db = db)
```
To find out how much data there is in this database, look at the number of rows as an indication. Note that this operation may be slow for large databases, as every tables in the database needs to be queried.
```{r}
get_nrows(db)
```
Now let's find out how to actually retrieve data from the database. There is a simple function for this, which is called `get_data()`. With this function you can extract any kind of data you want. Make sure you also run `?get_data` for an overview of how to use this (or any other) function. In most functions, you can also leave arguments empty to retrieve all data (e.g. not in a specific time window).
```{r}
get_data(
db = db, # the ACTIVE database connection, open with open_db AND save to a variable
sensor = "Pedometer", # A sensor name, see mpathsenser::sensors for the full list
participant_id = "2784", # A participant ID, see get_participants
start_date = "2022-06-14", # An optional start date, in the format YYYY-MM-DD
end_date = "2022-06-15" # An optional end date, in the format YYYY-MM-DD
)
```
A more comprehensive guide is provided in the [Get Started vignette](https://ppw-okpiv.pages.gitlab.kuleuven.be/researchers/u0134047/mpathsenser/articles/mpathsenser.html).
## Reference
For an overview of all functions in this package, see the [mpathsenser Reference Site](https://ppw-okpiv.pages.gitlab.kuleuven.be/researchers/u0134047/mpathsenser/reference/index.html). The database schema used in this package can be found [here](https://gitlab.kuleuven.be/ppw-okpiv/researchers/u0134047/mpathsenser/-/blob/master/inst/extdata/mpathsenser_db.png).
## Getting help
If you encounter a clear bug or need help getting a function to run, please file an issue with a minimal reproducible example on [Gitlab](https://gitlab.kuleuven.be/ppw-okpiv/researchers/u0134047/mpathsenser/-/issues).
## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
```{r include=FALSE}
close_db(db)
```
CodeMeta (codemeta.json)
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "mpathsenser",
"description": "Overcomes one of the major challenges in mobile (passive) sensing, namely being able to preprocess the raw data that comes from a mobile sensing app, specifically 'm-Path Sense' <https://m-path.io>. The main task of 'mpathsenser' is therefore to read 'm-Path Sense' 'JSON' files into a database and provide several convenience functions to aid in data processing.",
"name": "mpathsenser: Process and Analyse Data from m-Path Sense",
"relatedLink": "https://ppw-okpiv.pages.gitlab.kuleuven.be/researchers/u0134047/mpathsenser/",
"codeRepository": "https://gitlab.kuleuven.be/ppw-okpiv/researchers/u0134047/mpathsenser/",
"issueTracker": "\n https://gitlab.kuleuven.be/ppw-okpiv/researchers/u0134047/mpathsenser/-/issues/",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "1.2.2",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)",
"author": [
{
"@type": "Person",
"givenName": "Koen",
"familyName": "Niemeijer",
"email": "koen.niemeijer@kuleuven.be",
"@id": "https://orcid.org/0000-0002-0816-534X"
}
],
"contributor": [
{
"@type": "Person",
"givenName": "Kristof",
"familyName": "Meers",
"email": "kristof.meers@kuleuven.be",
"@id": "https://orcid.org/0000-0002-9610-7712"
}
],
"copyrightHolder": [
{
"@type": "Organization",
"name": "KU Leuven"
}
],
"funder": [
{
"@type": "Organization",
"name": "KU Leuven"
}
],
"maintainer": [
{
"@type": "Person",
"givenName": "Koen",
"familyName": "Niemeijer",
"email": "koen.niemeijer@kuleuven.be",
"@id": "https://orcid.org/0000-0002-0816-534X"
}
],
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "cli",
"name": "cli",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=cli"
},
{
"@type": "SoftwareApplication",
"identifier": "curl",
"name": "curl",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=curl"
},
{
"@type": "SoftwareApplication",
"identifier": "ggplot2",
"name": "ggplot2",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=ggplot2"
},
{
"@type": "SoftwareApplication",
"identifier": "httr",
"name": "httr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=httr"
},
{
"@type": "SoftwareApplication",
"identifier": "kableExtra",
"name": "kableExtra",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=kableExtra"
},
{
"@type": "SoftwareApplication",
"identifier": "knitr",
"name": "knitr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=knitr"
},
{
"@type": "SoftwareApplication",
"identifier": "lintr",
"name": "lintr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=lintr"
},
{
"@type": "SoftwareApplication",
"identifier": "progressr",
"name": "progressr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=progressr"
},
{
"@type": "SoftwareApplication",
"identifier": "rmarkdown",
"name": "rmarkdown",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rmarkdown"
},
{
"@type": "SoftwareApplication",
"identifier": "rvest",
"name": "rvest",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rvest"
},
{
"@type": "SoftwareApplication",
"identifier": "sodium",
"name": "sodium",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=sodium"
},
{
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"version": ">= 3.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=testthat"
},
{
"@type": "SoftwareApplication",
"identifier": "vroom",
"name": "vroom",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=vroom"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 4.0.0"
},
"2": {
"@type": "SoftwareApplication",
"identifier": "DBI",
"name": "DBI",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=DBI"
},
"3": {
"@type": "SoftwareApplication",
"identifier": "dbplyr",
"name": "dbplyr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=dbplyr"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "dplyr",
"name": "dplyr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=dplyr"
},
"5": {
"@type": "SoftwareApplication",
"identifier": "furrr",
"name": "furrr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=furrr"
},
"6": {
"@type": "SoftwareApplication",
"identifier": "jsonlite",
"name": "jsonlite",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=jsonlite"
},
"7": {
"@type": "SoftwareApplication",
"identifier": "lifecycle",
"name": "lifecycle",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=lifecycle"
},
"8": {
"@type": "SoftwareApplication",
"identifier": "lubridate",
"name": "lubridate",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=lubridate"
},
"9": {
"@type": "SoftwareApplication",
"identifier": "purrr",
"name": "purrr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=purrr"
},
"10": {
"@type": "SoftwareApplication",
"identifier": "rlang",
"name": "rlang",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rlang"
},
"11": {
"@type": "SoftwareApplication",
"identifier": "RSQLite",
"name": "RSQLite",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=RSQLite"
},
"12": {
"@type": "SoftwareApplication",
"identifier": "stats",
"name": "stats"
},
"13": {
"@type": "SoftwareApplication",
"identifier": "tibble",
"name": "tibble",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tibble"
},
"14": {
"@type": "SoftwareApplication",
"identifier": "tidyr",
"name": "tidyr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tidyr"
},
"SystemRequirements": null
},
"fileSize": "4931.489KB",
"citation": [
{
"@type": "ScholarlyArticle",
"datePublished": "2023",
"author": [
{
"@type": "Person",
"givenName": "Koen",
"familyName": "Niemeijer"
},
{
"@type": "Person",
"givenName": "Merijn",
"familyName": "Mestdagh"
},
{
"@type": "Person",
"givenName": "Stijn",
"familyName": "Verdonck"
},
{
"@type": "Person",
"givenName": "Kristof",
"familyName": "Meers"
},
{
"@type": "Person",
"givenName": "Peter",
"familyName": "Kuppens"
}
],
"name": "Combining Experience Sampling and Mobile Sensing for Digital Phenotyping With m-Path Sense: Performance Study",
"identifier": "10.2196/43296",
"pagination": "e43296",
"@id": "https://doi.org/10.2196/43296",
"sameAs": "https://doi.org/10.2196/43296",
"isPartOf": {
"@type": "PublicationIssue",
"issueNumber": "1",
"datePublished": "2023",
"isPartOf": {
"@type": [
"PublicationVolume",
"Periodical"
],
"volumeNumber": "7",
"name": "JMIR Formative Review"
}
}
}
],
"developmentStatus": "https://www.repostatus.org/#active"
}
GitHub Events
Total
- Push event: 2
Last Year
- Push event: 2
Dependencies
DESCRIPTION
cran
- R >= 4.0.0 depends
- DBI * imports
- RSQLite * imports
- dbplyr * imports
- dplyr * imports
- furrr * imports
- jsonlite * imports
- lifecycle * imports
- lubridate * imports
- magrittr * imports
- purrr * imports
- rlang * imports
- stats * imports
- tibble * imports
- tidyr * imports
- cli * suggests
- curl * suggests
- ggplot2 * suggests
- httr * suggests
- knitr * suggests
- lintr * suggests
- progressr * suggests
- rmarkdown * suggests
- rvest * suggests
- sodium * suggests
- testthat >= 3.0.0 suggests
- vroom * suggests
Dockerfile
docker
- rocker/tidyverse devel build