-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_documentation.qmd
108 lines (73 loc) · 4.07 KB
/
data_documentation.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Documenting Your Dataset {#sec-datadocumentation}
```{r, include=FALSE}
library(washr)
```
In the next steps, the goal is to document not only the dataset itself but also the functions and the package as a whole. The individual steps are visualized in the figure below.
![](images/documenting.png){fig-align="center" style="border: 1px solid black;"}
## Setting Up and Writing Documentation with Roxygen
To begin documenting your dataset, start by initializing Roxygen documentation. Open your R console within the project and run the following command:
```{r}
setup_roxygen()
```
This will create the necessary documentation files in the `R/` folder of your project, setting up the foundation for detailed documentation.
### Writing Documentation
Once the documentation files are generated, navigate to the `R/` folder in your project. Each file in this folder, with a `.R` extension, represents a dataset or function. Open these files and provide a human-readable title and description using Roxygen comments (lines that start with `#'`). For instance, you could use the following format to document your dataset:
```
#' Title of Your Dataset
#'
#' A brief description of what the dataset contains and its purpose.
#'
#' @format A data frame with X rows and Y columns:
#' \describe{
#' \item{column1}{Description of column1}
#' \item{column2}{Description of column2}
#' ...
#' }
#' @source Where the data comes from (if applicable)
"dataset_name"
```
This method allows you to provide clear, concise details about each dataset, ensuring that users understand its structure and purpose.
### Updating Your GitHub Repository
Once you've completed the documentation, it’s time to update your GitHub repository. In RStudio, go to the "Git" tab. Stage all the changed files by checking the boxes next to them, then click "Commit". Write a meaningful commit message, such as "Add Roxygen documentation for dataset", and click "Push" to update your repository with the latest changes.
### Finalizing and Installing the Documentation
Now that your documentation is written, run the following commands in your R console:
```{r}
devtools::document()
devtools::check()
devtools::install()
```
These commands will generate the documentation from your Roxygen comments, check for any issues in the package, and install it locally. If you receive a warning about the license, don’t worry, as it will be addressed in the next section.
## Updating the DESCRIPTION File
To complete your package documentation, you’ll need to update the `DESCRIPTION` file with author information and other key details.
### Adding Yourself as an Author
In your R console, add yourself as the author and maintainer by running:
```{r}
use_author(
given = "Your First Name",
family = "Your Last Name",
role = c("aut", "cre"),
email = "your.email@example.com",
comment = c(ORCID = "XXXX-XXXX-XXXX-XXXX")
)
```
Here, `aut` indicates that you are an author, and `cre` designates you as the creator or maintainer of the package.
### Documenting Other Contributors
To ensure proper credit is given, create a new issue in your GitHub repository titled "Author Information for DESCRIPTION File". List all contributors, including their full name, email address, role (e.g., `aut` for authors or `ctb` for contributors), and ORCID (if applicable).
For each additional contributor, run a similar command:
```{r}
use_author(given = "Coauthor First Name", family = "Coauthor Last Name", role = "aut")
```
### Updating the DESCRIPTION File
After adding all contributors, open the `DESCRIPTION` file in your project and ensure the title and description reflect the purpose of your package accurately. Then, in your R console, run:
```{r}
update_description()
```
This will update fields such as version, authors, and dependencies. Review the `DESCRIPTION` file to make sure all information is accurate.
### Final Documentation Check
To complete the process, run the following commands again:
```{r}
devtools::document()
devtools::check()
devtools::install()
```
These steps will ensure your package is fully documented, checked for errors, and ready for use.