The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
You can install the latest version of mpathsenser from CRAN:
Alternatively, you can install the development version from my Gitlab repo. First, make sure you have Rtools (Windows, Linux) or XCode installed. For XCode, register as an Apple Developer (don’t worry, it’s free) and then run xcode-select --install
in a terminal. Then, run the following code in R:
Specify a path variable to wherever you put the JSON files. Make sure to use / and not a backslash.
If you haven’t done so, unzip all files.
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 are not properly closed and hence cannot be read by JSON readers. So, we must first test if all files are in a valid JSON format and fix those that are not.
to_fix <- test_jsons(path = path)
# Fix JSON files if there are any
if (to_fix != "") {
fix_jsons(path = path, files = to_fix, parallel = TRUE)
}
If you want to put the database in a different directory than the files, create it first and then pass it to import
.
If not, you can simply call import
to start reading in the files.
import(path = path, dbname = "some_db.db")
# In the case of an existing database or database in another location:
# import(path = path, db = db)
Note that import
always closes the database connection.
To establish a database connection, use open_db
. Don’t forget to save it to a variable!
To find out which participants are in the database (or rather their participant numbers):
We can also check what device they are using (which can be found in the Device table of the database).
To find out how much data there is in this database, look at the number of rows as an indication. You may notice from running this function that it’s not exactly fast. That’s because it is a lot of data. So be careful when computing things, or you’ll be stuck for a long time (especially when working with accelerometer and gyroscope)
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).
get_data(
db = db, # the ACTIVE database connection, open with open_db AND save to a variable
sensor = "Activity", # A sensor name, see mpathsenser::sensors for the full list
participant_id = "12345", # A participant ID, see get_participants
start_date = "2021-11-14", # An optional start date, in the format YYYY-MM-DD
end_date = "2021-11-15" # An optional end date, in the format YYYY-MM-DD
)
For an overview of all functions in this package, see the mpathsenser Reference Site. The database schema used in this package can be found here.
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.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.