Skip to content

Commit

Permalink
Vignette / start writing readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstackhouse committed Sep 11, 2023
1 parent a3f8d5b commit e08a41c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ admiraltemplate*.tgz

# Docs
docs/
inst/doc
31 changes: 0 additions & 31 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,6 @@ output: md_document

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
link <- function(text, url) {
return(
paste0(
"[", text, "]",
"(", url, ")"
)
)
}
dyn_link <- function(text,
base_url,
relative_url = "",
# Change to TRUE when admiral adopts multiversion docs
is_multiversion = TRUE,
multiversion_default_ref = "main") {
url <- paste(base_url, relative_url, sep = "/")
if (is_multiversion) {
url <- paste(
base_url,
Sys.getenv("BRANCH_NAME", multiversion_default_ref),
relative_url,
sep = "/"
)
}
return(link(text, url))
}
# Other variables
```

<!-- Please do not edit the README.md file as it is auto-generated after PR merges. Only edit the README.Rmd file -->
Expand All @@ -41,7 +14,3 @@ dyn_link <- function(text,

<!-- badges: end -->

## Table of Contents


## Extension Expectations
2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
68 changes: 68 additions & 0 deletions vignettes/getting_started.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
title: "Getting Started"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Getting Started}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

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

```{r setup}
library(datasetjson)
```

# Using **datasetjson**

**datasetjson** works by allowing you to take a data frame and apply the necessary attributes required for the CDISC Dataset JSON. The goal is to make this experience simple. Before you can write a Dataset JSON file to disk, you first need to build the Dataset JSON object. An example call looks like this:

```{r sample_call, eval=FALSE}
ds_json <- dataset_json(iris, "IG.IRIS", "IRIS", "Iris", iris_items)
```

This is the minimum information required to provide to create a `datasetjson` object.

The parameters here can be described as follows:

- The input data frame `iris`
- The `item_id`, which can be described as the "Object of Dataset", which is a key value is a unique identifier for the dataset, corresponding to ItemGroupDef/@OID in Define-XML.
- `name`, which is the dataset name
- `label`, which is the dataset label, and finally
- `items`, which is the variable level metadata for your dataset.

The `items` parameter is special here, in that you provide a data frame with the necessary variable metadata. Take a look at the `iris_items` data frame.

```{r iris_items}
iris_items
```

This data frame has 7 columns, 4 of which are strictly required:

| **Variable Name** | **Description** |
|-------------------|-----------------------------------------------------------------------------------------------------------------|
| OID | Unique identifier for Variable. Must correspond to ItemDef/@OID in Define-XML. |
| name | Name for Variable |
| label | Label for Variable |
| type | Data type for Variable |
| length | Length for Variable |
| keySequence | Indicates that this item is a key variable in the dataset structure. It also provides an ordering for the keys. |
| displayFormat | Display format supports data visualization of numeric float and date values. |

The data within this dataframe ultimate populates the `items` element of the Dataset JSON file. The OID, name, label, and type columns are all required and must be populated for each variable. Note that the type column has a list of allowable values:

- string
- integer
- float
- double
- decimal
- boolean

This information must be provided directly by the user. Note that no type conversions of your data are performed by the `datasetjson` package. The displayFormat column inherently refers to display formats used within SAS.

## Setting Other Data Attributes

0 comments on commit e08a41c

Please sign in to comment.