---
title: "Rename ILSAmerge files"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Rename ILSAmerge files}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE
)
```

```{r setup, echo=FALSE}
library(ILSAmerge)
```

Quiet often ILSA file names come in codes representing different respondents,
and cycles. To make this codes comprehensible, we can use `ILSArename()` to give new
names to merged files.

First, we need to use `ILSAmerge()` to merge the files:

```{r,echo=FALSE}
unlink(file.path(tempdir(),"REDS2021"),recursive = TRUE)
```

```{r, eval=TRUE}
dir.create(file.path(tempdir(),"REDS2021"),showWarnings = FALSE)

ILSAmerge(inputdir = system.file("extdata/reds", package = "ILSAmerge"), 
          outputdir = file.path(tempdir(),"REDS2021"), 
          filetype = c("rds", "zsav", "sav"),quiet = TRUE)
```

This will create 3 files with codes for respondent and cycle:

```{r, eval=TRUE}
list.files(file.path(tempdir(),"REDS2021"))
```

With `ILSArename()` we can convert these names:

```{r, eval=TRUE}
ILSArename(inputdir = file.path(tempdir(),"REDS2021"))
list.files(file.path(tempdir(),"REDS2021"))

```
```{r,echo=FALSE}
unlink(file.path(tempdir(),"REDS2021"),recursive = TRUE)
```