sum_up computes the sum up value for each sample (row) of a multi-channel signal.

sum_up(df, axes = NULL)

Arguments

df

dataframe. multi-channel signal, with the first column being the timestamp in POSXct format.

axes

numerical vector. Specify the column indices for each axis. When this value is NULL, the function assumes the axes are starting from column 2 to the end. Default is NULL.

Value

dataframe. The transformed dataframe will have the same number of rows as input dataframe but only two columns, with the first being timestamps and second being the sum up values.

Details

This function takes a dataframe of a multi-channel signal as input, and then computes the sum of each row and returns a transformed dataframe with two columns.

How is it used in MIMS-unit algorithm?

This function is used to combine MIMS-unit values on each axis into a single value after aggregating over each epoch using aggregate_for_mims.

See also

vector_magnitude

Other transformation functions: compute_orientation(), vector_magnitude()

Examples

  # Use the first 10 rows of the sample data as an example
  df = sample_raw_accel_data[1:10,]
  df
#>      HEADER_TIME_STAMP     X      Y      Z
#> 1  2016-01-15 11:00:00 0.148 -0.438  0.016
#> 2  2016-01-15 11:00:00 0.215 -0.418 -0.023
#> 3  2016-01-15 11:00:00 0.266 -0.402 -0.012
#> 4  2016-01-15 11:00:00 0.336 -0.430  0.012
#> 5  2016-01-15 11:00:00 0.430 -0.320  0.000
#> 6  2016-01-15 11:00:00 0.535 -0.258  0.004
#> 7  2016-01-15 11:00:00 0.641 -0.348  0.020
#> 8  2016-01-15 11:00:00 0.777 -0.418  0.023
#> 9  2016-01-15 11:00:00 0.938 -0.359  0.043
#> 10 2016-01-15 11:00:00 1.113 -0.234  0.055

  # By default, the function will assume columns starting from 2 to be axial
  # values.
  sum_up(df)
#>      HEADER_TIME_STAMP SUMUP_X_Y_Z
#> 1  2016-01-15 11:00:00      -0.274
#> 2  2016-01-15 11:00:00      -0.226
#> 3  2016-01-15 11:00:00      -0.148
#> 4  2016-01-15 11:00:00      -0.082
#> 5  2016-01-15 11:00:00       0.110
#> 6  2016-01-15 11:00:00       0.281
#> 7  2016-01-15 11:00:00       0.313
#> 8  2016-01-15 11:00:00       0.382
#> 9  2016-01-15 11:00:00       0.622
#> 10 2016-01-15 11:00:00       0.934

  # Or, you may specify the column indices yourself
  sum_up(df, axes=c(2,3,4))
#>      HEADER_TIME_STAMP SUMUP_X_Y_Z
#> 1  2016-01-15 11:00:00      -0.274
#> 2  2016-01-15 11:00:00      -0.226
#> 3  2016-01-15 11:00:00      -0.148
#> 4  2016-01-15 11:00:00      -0.082
#> 5  2016-01-15 11:00:00       0.110
#> 6  2016-01-15 11:00:00       0.281
#> 7  2016-01-15 11:00:00       0.313
#> 8  2016-01-15 11:00:00       0.382
#> 9  2016-01-15 11:00:00       0.622
#> 10 2016-01-15 11:00:00       0.934

  # Or, if you only want to consider x and y axes
  sum_up(df, axes=c(2,3))
#>      HEADER_TIME_STAMP SUMUP_X_Y
#> 1  2016-01-15 11:00:00    -0.290
#> 2  2016-01-15 11:00:00    -0.203
#> 3  2016-01-15 11:00:00    -0.136
#> 4  2016-01-15 11:00:00    -0.094
#> 5  2016-01-15 11:00:00     0.110
#> 6  2016-01-15 11:00:00     0.277
#> 7  2016-01-15 11:00:00     0.293
#> 8  2016-01-15 11:00:00     0.359
#> 9  2016-01-15 11:00:00     0.579
#> 10 2016-01-15 11:00:00     0.879

  # Or, just return the chosen column
  sum_up(df, axes=c(2))
#>      HEADER_TIME_STAMP SUMUP_X
#> 1  2016-01-15 11:00:00   0.148
#> 2  2016-01-15 11:00:00   0.215
#> 3  2016-01-15 11:00:00   0.266
#> 4  2016-01-15 11:00:00   0.336
#> 5  2016-01-15 11:00:00   0.430
#> 6  2016-01-15 11:00:00   0.535
#> 7  2016-01-15 11:00:00   0.641
#> 8  2016-01-15 11:00:00   0.777
#> 9  2016-01-15 11:00:00   0.938
#> 10 2016-01-15 11:00:00   1.113