Learn R Programming

gmwm (version 2.0.0)

imu: Create an IMU Object

Description

Builds an IMU object that provides the program with gyroscope, accelerometer, and axis information per column in the dataset.

Usage

imu(data, gyros = NULL, accels = NULL, axis = NULL, freq = NULL, unit = NULL, name = NULL)

Arguments

data
A vector which contains data, or a matrix or data.frame which contains the data in each column.
gyros
A vector that contains the index of columns where gyroscope data (such as Gyro. X, Gyro. Y and Gyro. Z) is placed.
accels
A vector that contains the index of columns where accelerometer data (such as Accel. X, Accel. Y and Accel. Z) is placed.
axis
A vector that indicates the axises, such as 'X', 'Y', 'Z'.
freq
An integer that provides the frequency for the data.
unit
A string that contains the unit expression of the frequency. Default value is NULL.
name
A string that provides an identifier to the data. Default value is NULL.

Value

An imu object in the following attributes:
sensor
A vector that indicates whether data contains gyroscope sensor, accelerometer sensor, or both.
num.sensor
A vector that indicates how many columns of data are for gyroscope sensor and accelerometer sensor.
axis
Axis value such as 'X', 'Y', 'Z'.
freq
Observations per second.
unit
String representation of the unit.
name
Name of the dataset.

Details

data can be a numeric vector, matrix or data frame.

gyros and accels cannot be NULL at the same time, but it will be fine if one of them is NULL. Also, in order to plot the graph, the length of gyros and accels are restricted to be equal.

In axis, duplicate elements are not alowed. If one of parameters between gyros and accels is NULL, specify the axis for each column of data. Check example 1 for help. If both of them are not NULL, specify the axis only for one parameter (gyros or accels). Check example 3 for help.

axis will be automatically generated if there are less than or equal to 3 axises.

Examples

Run this code
## Not run: 
# if(!require("imudata")){
#    install_imudata()
#    library("imudata")
# }
# 
# data(imu6)
# 
# # Example 1 - Only gyros
# test1 = imu(imu6, gyros = 1:3, axis = c('X', 'Y', 'Z'), freq = 100)
# df1 = wvar.imu(test1)
# plot(df1)
# 
# # Example 2 - One gyro and one accelerometer
# test2 = imu(imu6, gyros = 1, accels = 4, freq = 100)
# df2 = wvar.imu(test2)
# plot(df2)
# 
# # Example 3 - 3 gyros and 3 accelerometers
# test3 = imu(imu6, gyros = 1:3, accels = 4:6, axis = c('X', 'Y', 'Z'), freq = 100)
# df3 = wvar.imu(test3)
# plot(df3)
# 
# # Example 4 - Custom axis
# test4 = imu(imu6, gyros = 1:2, accels = 4:5, axis = c('A', 'B'), freq = 100)
# df4 = wvar.imu(test4)
# plot(df4)
# ## End(Not run)

Run the code above in your browser using DataLab