export_to_actilife
exports the input dataframe as a csv file that is
compatible with Actilife.
export_to_actilife(
df,
filepath,
actilife_version = "6.13.3",
firmware_version = "1.6.0"
)
dataframe. Input accelerometer data. The first column is timestamp in POSXlct format, and the rest columns are accelerometer values in g (\(9.81m/s^2\)).
string. The output filepath.
string. The Actilife version number to be added to the header. Default is "6.13.3", that was used by the algorithm during development.
string. The firmware version number to be added to the header. This is supposed to be the firmware version of the Actigraph devices. We did not see any usage of the number during the computation of Actigraph counts by Actilife, so it may be set with an arbitrary version code seen in any Actigraph devices. We use default version code "1.6.0".
No return value.
This function takes an input accelerometer dataframe and exports it in Actilife RAW CSV format with a prepended a madeup header. The exported file csv file has compatible header, column names, timestamp format with Actilife and can be imported directly into Actilife software.
This function is an utility function that was used to convert validation data into Actilife RAW CSV format so that we can use Actilife to compute Actigraph counts values for these data.
Other File I/O functions:
import_actigraph_count_csv()
,
import_actigraph_csv_chunked()
,
import_actigraph_csv()
,
import_actigraph_meta()
,
import_activpal3_csv()
,
import_enmo_csv()
,
import_mhealth_csv_chunked()
,
import_mhealth_csv()
# Use the first 5 rows from sample data
df = sample_raw_accel_data[1:5,]
head(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
# Save to current path with default mocked actilife and firmware versions
filepath = tempfile()
export_to_actilife(df, filepath)
# The saved file will have the same format as Actigraph csv files
readLines(filepath)
#> [1] "------------ Data File Created By Actigraph GT3X+ ActiLife v6.13.3 Firmware v1.6.0 date format M/d/yyyy at 100 Hz Filter Nomral -----------"
#> [2] "Serial Number: TAS1E00000000"
#> [3] "Start Time 11:00:00"
#> [4] "Start Date 01/15/2016"
#> [5] "Epoch Period (hh:mm:ss) 00:00:00"
#> [6] "Download Time 11:00:00"
#> [7] "Download Date 01/15/2016"
#> [8] "Current Memory Address 0"
#> [9] "Current Battery Voltage: 4.19 Mode = 12"
#> [10] "--------------------------------------------------"
#> [11] "Timestamp,Accelerometer X,Accelerometer Y,Accelerometer Z"
#> [12] "01/15/2016 11:00:00.013,0.148,-0.438,0.016"
#> [13] "01/15/2016 11:00:00.025,0.215,-0.418,-0.023"
#> [14] "01/15/2016 11:00:00.038,0.266,-0.402,-0.012"
#> [15] "01/15/2016 11:00:00.049,0.336,-0.43,0.012"
#> [16] "01/15/2016 11:00:00.062,0.43,-0.32,0"
# Cleanup
file.remove(filepath)
#> [1] TRUE