Wrote the final import function for the cortrium C3 recorded data into R - importing the accelererometer data for all three axis. The complete readCortrium package is available on GitHub.

# load the libraries
library(ggplot2)
library(reshape2)
library(readCortrium)
## Loading required package: signal
## 
## Attaching package: 'signal'
## 
## The following objects are masked from 'package:stats':
## 
##     filter, poly
# reading accelerometer data 
accelData <- readAccel(dirname) # dirname is a folder on my computer 
head(accelData, 5) # first 5 rows of data
##   accelX  accelY  accelZ
## 1 0.2852 -1.0000 -0.1484
## 2 0.2461 -0.9961 -0.1641
## 3 0.2695 -0.9844 -0.1992
## 4 0.2227 -0.9961 -0.1914
## 5 0.1914 -1.0000 -0.2305
str(accelData) # structure of the data frame
## 'data.frame':    133632 obs. of  3 variables:
##  $ accelX: num  0.285 0.246 0.27 0.223 0.191 ...
##  $ accelY: num  -1 -0.996 -0.984 -0.996 -1 ...
##  $ accelZ: num  -0.148 -0.164 -0.199 -0.191 -0.23 ...
##  - attr(*, "measurementStart")= POSIXct, format: "2014-10-26 09:02:41"
##  - attr(*, "measurementEnd")= POSIXct, format: "2014-10-26 10:31:46"
# transform data for ploting with ggplot
ggplotAccelData <- addTimestamp(dataframe = accelData, frequency = 25)
ggplotAccelData <- melt(data = ggplotAccelData, measure.vars = c("accelX","accelY","accelZ"))
head(ggplotAccelData)
##             timestamp variable  value
## 1 2014-10-26 09:02:41   accelX 0.2852
## 2 2014-10-26 09:02:41   accelX 0.2461
## 3 2014-10-26 09:02:41   accelX 0.2695
## 4 2014-10-26 09:02:41   accelX 0.2227
## 5 2014-10-26 09:02:41   accelX 0.1914
## 6 2014-10-26 09:02:41   accelX 0.1875
# plot the data
p <- ggplot(data=ggplotAccelData) + geom_point(aes(x=timestamp, y=value, group=variable, color=variable )) + 
  scale_x_datetime() + scale_y_continuous() + 
  theme_bw()
p

plot of chunk unnamed-chunk-1

The graph shows cca. an hour and a half of data for all three accelerometer channels. I’m actually not certain about the units used on the y axis. I was walking from arround 9:00 to 9:15, then waiting for a bus (that didn’t show up) till around 9:35 and afterwards hithching a ride for some twenty minutes, again walking for some time (and after that I don’t recall exactly). Anyway, where I was walking there seems to be greater variability in the measurement. Where I was stiitng, the Y and Z values seem to come together (different torso position than in walking?). I’m not doing any particular analysis with this data at the moment, just finishing up the import functions and testing them…