---
title: "Frequently Asked Questions"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{FAQ}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

options(rmarkdown.html_vignette.check_title = FALSE)

```

Below are some frequently asked questions about the **defineR** package. Click
on the links below to navigate to the full question and answer content.

## Index{#top}

* [What is a define.xml?](#define)
* [How do I generate a define.xml for ADaM?](#adam)
* [Where can I get a metadata template?](#template)
* [Can I generate a define.xml for SEND?](#send)
* [Can I use my XPT files to generate a metadata file?](#xpt)
* [Can I use other files to generate a metadata file?](#other)
* [Does the package support define 2.1?](#version)
* [What if I want to use a different XSLT style sheet?](#styles)
* [Can it read in an existing define.xml?](#existing)
* [Is this the same template as the SAS® toolkit?](#sas)


## Content

### What is a define.xml? {#define}

**Q:** I don't quite understand what this is about.  What is a define.xml?
Do I need one?

**A:** The define.xml is a special XML file used to describe data
sent to regulatory bodies for drug applications.  If you don't know what it is,
then you don't need one.

[top](#top) 

******

### How do I generate a define.xml for ADaM? {#adam}

**Q:** The **defineR** generator seems to always create a define.xml 
for SDTM.  I want to create one for ADaM.  How can I do that?

**A:** There is a parameter called `type` on the `write_define()` function
that you can use to specify an SDTM or ADaM define. Here is an example:
```
# Get temporary directory for output
tmp <- tempdir()

# Create demo spreadsheet
pth <- write_metadata(tmp, type = "adam", demo = TRUE)

# Generate define for ADaM
res <- write_define(pth, tmp, type = "adam")

# View XML
# file.show(file.path(tmp, "define.adam.xml"))

# View check report
# file.show(file.path(tmp, "check.adam.pdf"))

# View HTML
# file.show(file.path(tmp, "define.adam.html"))

```

[top](#top) 

******

### Where can I get a metadata template? {#template}

**Q:** I'd like to try out **defineR**.  Where can I get a starting template?

**A:** You can generate a starting template. It it recommended to start 
with the demo template, rather than a blank template.  To do that, 
set the `demo` option on the `write_metadata()` function.  Like this:
```{r eval=FALSE, echo=TRUE} 

# Get temporary directory
tmp <- tempdir()

# Create metadata template
write_metadata(tmp, 
               type = "<sdtm or adam>", 
               demo = TRUE)

```

[top](#top) 

******

### Can I generate a define.xml for SEND? {#send}

**Q:** I am working on an animal study, and need to generate a define.xml
for SEND.  Can **defineR** do that?

**A:** Not at this time.  If you desire this feature, please submit 
a request to the GitHub [issue list](https://github.com/dbosak01/defineR/issues). 

[top](#top) 

******

### Can I use my XPT files to generate a metadata file? {#xpt}

**Q:** I have some XPT files already.  Can I use them to generate metadata?


**A:** Yes. Use the `write_metadata()` function, and supply the 
`src_dir` parameter with the directory that contains your XPT files.  Like this:
```{r eval=FALSE, echo=TRUE} 

# Get temporary directory
tmp <- tempdir()

# Create metadata template
write_metadata(tmp, 
               type = "<sdtm or adam>", 
               src_dir = "<source data path>")

```

[top](#top) 

******

### Can I use other files to generate a metadata file? {#other}

**Q:** What if I don't have XPT files? Can I generate metadata
from Excel files or SAS datasets?

**A:** Not in the current release. If you desire this feature,
please submit a request to the GitHub 
[issue list](https://github.com/dbosak01/defineR/issues), and we can
up the priority.

[top](#top)

****** 

### Does the package support define 2.1? {#version}

**Q:** Our organization is getting ready for define version 2.1.  Does
the **defineR** package support it?

**A:** Not yet. Define
version 2.1 will be coming in a future release.

[top](#top)

****** 

### What if I want to use a different XSLT style sheet? {#styles}

**Q:** I have a custom style sheet, and want to use it with 
**defineR**.  Can I do that?

**A:** Yes.  There is a global option to specify a custom style sheet.
The option is called "defineR.xslt", and you can set it as follows:
```{r eval=FALSE, echo=TRUE} 
options("defineR.xslt" = "<path>")

```

[top](#top)

****** 

### Can it read in an existing define.xml? {#existing}

**Q:** I have a define.xml alread and want to create a 
metadata template from it. Can this package do it?

**A:** Not at this time. If there is sufficient interest in this feature,
we can add it.

[top](#top)

****** 

### Is this the same template as the SAS® toolkit? {#sas}

**Q:** This template looks similar to the template in
the SAS® Clinical Standards Toolkit.  Are they the same?

**A:** No.  The metadata template for the **defineR** package
was taken from the book "Implementing CDISC Using SAS: An End-to-End Guide" 
by Chris Holland and Jack Shostak.  This book was published by SAS Institute®, 
but the metadata format is different than what was used for the 
SAS® Clinical Standards Toolkit.

[top](#top)

****** 
<!--
### Question 2? {#validation}

**Q:** Question here.

**A:** Answer here.

[top](#top)

****** 

### Question 2? {#outputs}

**Q:** Question here.

**A:** Answer here.

[top](#top)

****** 

### Question 2? {#colors}

**Q:** Question here.

**A:** Answer here.

[top](#top)

****** 
-->
<!-- ### Question 2? {#q2} -->

<!-- **Q:** Question here. -->

<!-- **A:** Answer here. -->

<!-- [top](#top) -->

<!-- ****** -->

<!-- ### Question 1? {#q1} -->

<!-- **Q:** Question here. -->


<!-- **A:** Answer here. -->

<!-- [top](#top)  -->

<!-- ****** -->

