# NOT RUN {
default_ops = options()
options(digits.secs=3)
# Use the actigraph csv file shipped with the package
filepath = system.file('extdata', 'actigraph_timestamped.csv', package='MIMSunit')
# Check original file format
readLines(filepath)[1:15]
# Example 1: Load chunks every 2000 samples
results = import_actigraph_csv_chunked(filepath, chunk_samples=2000)
next_chunk = results[[1]]
close_connection = results[[2]]
# Check data as chunks, you can see chunks are shifted at each iteration.
n = 1
repeat {
df = next_chunk()
if (nrow(df) > 0) {
print(paste('chunk', n))
print(paste("df:", df[1, 1], '-', df[nrow(df),1]))
n = n + 1
}
else {
break
}
}
# Close connection after reading all the data
close_connection()
# Example 2: Close loading early
results = import_actigraph_csv_chunked(filepath, chunk_samples=2000)
next_chunk = results[[1]]
close_connection = results[[2]]
# Check data as chunks, you can see chunk time is shifting forward at each iteration.
n = 1
repeat {
df = next_chunk()
if (nrow(df) > 0) {
print(paste('chunk', n))
print(paste("df:", df[1, 1], '-', df[nrow(df),1]))
n = n + 1
close_connection()
}
else {
break
}
}
# Restore default options
options(default_ops)
# }
Run the code above in your browser using DataLab