---
title: "README of R package convertagd"
author: "David Donaire and Maëlle Salmon"
date: "`r Sys.Date()`"
output:
  md_document:
    variant: markdown_github
---
[![Build Status](https://travis-ci.org/maelle/convertagd.svg?branch=master)](https://travis-ci.org/maelle/convertagd)
[![Build status](https://ci.appveyor.com/api/projects/status/hmx054adptv65619?svg=true)](https://ci.appveyor.com/project/masalmon/convertagd-g4jkl)
[![codecov.io](https://codecov.io/github/maelle/convertagd/coverage.svg?branch=master)](https://codecov.io/github/maelle/convertagd?branch=master)

This is a package aimed at converting .agd files from Actigraph into data.frames. 

```{r, echo=FALSE, message=FALSE, warning=FALSE}
library("knitr")
```

# Installation

```{r, eval=FALSE}
library("devtools")
install_github("masalmon/convertagd")
```

# Converting a single file

`read_agd` is the function for reading a agd file and getting two tables out of it.

```{r, results='asis', warning=FALSE, message=FALSE}
library("convertagd")
file <- system.file("extdata", "dummyCHAI.agd", package = "convertagd")
testRes <- read_agd(file, tz = "GMT")
kable(testRes[["settings"]])
kable(head(testRes[["raw.data"]]))
```

# Converting all files in a directory

Suppose you have a lot of agd files in one directory. You can convert all of them at the same time, outside of memory, using the `batch_read_agd` function.

It takes the path to the directory as input and will save the results in the current working directory.

You will get two csv files for all agd files (`all_in_one = TRUE`) :

* settings.csv which is a table with 28 columns (the 28 settings names) and as many rows as there are agd files in the directory.

* raw_data.csv which is a table with all measurements for all files, with a column "file_name" for identifying the individual sets of measurements.

This is how a call to the function looks like:

```{r, eval=FALSE}
path_to_directory <- system.file("extdata", package = "convertagd")
batch_read_agd(path_to_directory, tz="GMT")

```
