LTER-LIFE / FDFDT

FAIR Data for Digital Twins
0 stars 0 forks source link

# FDFDT

FAIR Data for Digital Twins

Table of Contents

- [Project info](#project-info) - [Description](#description) - [Project partners](#project-partners) - [Deliverables](#deliverables) - [Datasets](#datasets) - [Style guide](#style-guide) - [Code metadata](#code-metadata) - [Code annotation](#annotation) - [Naming convention](#naming) - [Syntax](#syntax) - [Qualifying namespaces](#namespace)

Project info

Description

A collaborative project by DANS and NIOO about describing the workflow of making (long-tail) ecological data FAIR (findable, accessible, interoperable, reusable). This project is a pilot for LTER-LIFE, a large scale research infrastructure project that will facilitate the development of digital workflows and digital twins of entire ecosystems, in which both DANS and NIOO are partners.

Project partners

Deliverables

  • [ ] FAIR and mobilised datasets
  • [ ] Manual: how to FAIRify long-tail ecological data?
  • [ ] Workshop
  • [ ] Data type registry at DANS' Data Station

Datasets

A number of datasets of various origin, complexity, and structure will be made FAIR as part of this project.
Also see: NIOO-DANS Dataset Selection (
Google doc).
Note: ticked boxes are FAIRified datasets.

Style guide

The following guide describes the programming style that we use throughout this project. The goal of this guide is to make our code easier to read, share, and verify. Heavily influenced by the tidyverse style guide.

Code organisation

Code metadata

Every script should start with a metadata header including at least title, author, date of creation, and date of last update.

# Title: Create Style Guide
# Author: Stefan Vriend
# Created: 2023/12/14
# Last updated: 2023/12/15

Packages

Load all used packages at the top of the script, after the code metadata.

Code annotation

Comment your code. Each line of a comment should begin with the comment symbol and a single space: #. Comments should explain the why, not the what. Use section labels (Ctrl + Shift + R in Rstudio) to divide your code in sections.

Naming convention

File names

Names of files should all be meaningful. If files need to be run in order, prefix them with numbers (e.g., "0_retrieve-data.R", "1_process-data.R"). If you later realise that you’ve missed some steps, it’s tempting to use "2a", "2b", etc. However, it’s generally better to bite the bullet and rename all files.

Object and variable names

Use underscore in object and variables names to separate words. Generally, variable names should be nouns and function names should be verbs. Strive for names that are concise and meaningful. Where possible, avoid using names of existing functions and variables. Doing so will cause confusion for the readers of your code.

Syntax

Named arguments

A function’s arguments typically fall into two broad categories: one supplies the data to compute on; the other controls the details of computation. When you call a function, you may omit the names of data arguments, because they are used so commonly. If you override the default value of an argument, use the full name.

Example ```r # Preferred mean(1:10, na.rm = TRUE) mean(x = 1:10, na.rm = TRUE) # Not preferred mean(x = 1:10, , FALSE) ```

Spacing

Place spaces around all infix operators (=, +, -, <-, etc.). The same rule applies when using = in function calls. Always put a space after a comma, and never before (just like in regular English).

Example ```r average <- mean(length + width / 2, na.rm = TRUE) ```

Place a space before left parentheses, except in a function call.

Example ```r if (debug == TRUE) do(x) plot(x, y) ```

Curly braces

An opening curly brace should never go on its own line and should always be followed by a new line. A closing curly brace should always go on its own line, unless it’s followed by else. Always indent the code inside curly braces.

Example ```r if (y == 0) { log(x) } else { y ^ x } ```

Long lines

Try to limit your code to approximately 80 characters per line. This fits comfortably on a printed page with a reasonably sized font. If you find yourself running out of room, move to next line.

Quoting text

Try to stick to one quotation mark throughout the script. Preferred " ".

Tidyverse quotations

Use quotation marks around variable names when using functions that select variables, such as dplyr::select(), dplyr::rename(), or tidyr::pivot_longer(). It is not necessary to use quotation marks around variable names when using functions that filter or change variables, such as dplyr::filter(), dplyr::mutate(), dplyr::summarise().

Logical

Preferred TRUE and FALSE over T and F.

Qualifying namespaces

Users should explicitly qualify namespaces for all external functions.

Example ``` r dplyr::mutate() ```