README.md

ForcePlate

The goal of the ForcePlate package is to extract and process features to characterize of a recorded stabilogram.

Installation

You can install the development version of ForcePlate from GitHub with:

# install.packages("devtools")
devtools::install_github("joergheintz/ForcePlate")

Example: Derivatives of center point of force displacement

This is a basic example which shows you how to calculate a speed and acceleration.

 
\begin{aligned}
\dot{x_t} &= \frac{x_{t+1} - x_{t-1}}{2 \Delta t} \\
\ddot{x_t} &= \frac{x_{t+1} - 2 x_t + x_{t-1}}{2 \Delta t} \\
\end{aligned}

library(ForcePlate)
library(ggplot2)
library(kableExtra)
library(tibble)


## basic example code
      time = seq(0.01,6.28, 0.01)
      distance = sin(time)
      df = derivatives(y = distance, t = time)

## output
      as_tibble(rbind(head(df, 3), tail(df, 3)))
#> # A tibble: 6 × 4
#>       t        y    y.     y..
#>   <dbl>    <dbl> <dbl>   <dbl>
#> 1  0.01  0.0100  NA    NA     
#> 2  0.02  0.0200   1.00 -0.0200
#> 3  0.03  0.0300   1.00 -0.0300
#> 4  6.26 -0.0232   1.00  0.0232
#> 5  6.27 -0.0132   1.00  0.0132
#> 6  6.28 -0.00319 NA    NA

The function “derivatives” takes time and response as vectors and returns data frame. The chosen algorithm requires 3 data points to estimate velocity and acceleration the data set is therefore reduced n - 2 records. The data frame output shows head and tail for the data set with the NA.

# remove NA
      df = df[complete.cases(df), ]

# output
      ggplot(data = df) +  
      geom_point(aes(x = t, y = y ), color = 'blue', size = 1) + 
      geom_point(aes(x = t, y = y.), color = 'darkgreen', alpha = 1)  + 
      geom_point(aes(x = t, y = y.. ), color = 'darkorange', alpha = 0.5, shape = 21) +
            ylab(paste("y, y., y..")) + 
            xlab("time")



joergheintz/ForcePlate documentation built on June 26, 2022, 4:39 p.m.