Skip to content

Commit c092847

Browse files
authored
Merge pull request #71 from frictionlessdata/ropensci-submission
Add vignette and prepare for rOpenSci submission
2 parents df894f2 + 61f86a5 commit c092847

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+710
-335
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
^_pkgdown\.yml$
88
^docs$
99
^pkgdown$
10+
^cache$

DESCRIPTION

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: frictionless
22
Title: Read and Write Frictionless Data Packages
3-
Version: 0.8.0.9000
3+
Version: 0.9.0
44
Authors@R: c(
55
person("Peter", "Desmet", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0002-8442-8025")),
@@ -9,27 +9,32 @@ Authors@R: c(
99
person("Research Institute for Nature and Forest (INBO)", , ,
1010
"[email protected]", role = c("cph"))
1111
)
12-
Description: Read and write Frictionless Data Packages in a Tidyverse way.
12+
Description: Read and write Frictionless Data Packages. A Data Package
13+
(<https://specs.frictionlessdata.io/data-package/>) is a simple container
14+
format and standard to describe and package a collection of (tabular) data.
15+
It is typically used to publish FAIR and open datasets.
1316
License: MIT + file LICENSE
1417
URL: https://github.com/frictionlessdata/frictionless-r,
15-
https://frictionlessdata.github.io/frictionless-r
18+
https://frictionlessdata.github.io/frictionless-r/
1619
BugReports: https://github.com/frictionlessdata/frictionless-r/issues
1720
Imports:
1821
assertthat,
1922
dplyr,
2023
glue,
2124
httr,
2225
jsonlite,
23-
lifecycle,
2426
purrr,
2527
readr (>= 2.1.0),
2628
stringr
2729
Suggests:
30+
knitr,
2831
hms,
2932
lubridate,
30-
testthat (>= 3.0.0)
33+
testthat (>= 3.0.0),
34+
rmarkdown
3135
Config/testthat/edition: 3
3236
Encoding: UTF-8
3337
LazyData: true
3438
Roxygen: list(markdown = TRUE)
3539
RoxygenNote: 7.1.2
40+
VignetteBuilder: knitr

R/add_resource.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
#' Add a Data Resource
22
#'
3-
#' Adds a Tabular
4-
#' [Data Resource](https://specs.frictionlessdata.io/data-resource/)
5-
#' to a Data Package. The resource will be a
6-
#' [Tabular Data Resource](https://specs.frictionlessdata.io/tabular-data-resource/).
3+
#' Adds a Tabular [Data
4+
#' Resource](https://specs.frictionlessdata.io/data-resource/) to a Data
5+
#' Package.
6+
#' The resource will be a [Tabular Data
7+
#' Resource](https://specs.frictionlessdata.io/tabular-data-resource/).
78
#' The resource name can only contain lowercase alphanumeric characters plus
89
#' `.`, `-` and `_`.
910
#'
1011
#' @inheritParams read_resource
1112
#' @param df A data frame.
12-
#' @param schema List object describing a Table Schema for that data frame. If
13-
#' not provided, one will be created (using [create_schema()]).
13+
#' @param schema List object describing a Table Schema for that data frame.
14+
#' If not provided, one will be created (using [create_schema()]).
1415
#' @return Provided `package` with one additional resource.
16+
#' @family edit functions
1517
#' @export
1618
#' @examples
1719
#' # Load the example Data Package

R/check_package.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#'
66
#' @param package List object describing a Data Package.
77
#' @return `TRUE` or error.
8+
#' @family check functions
89
#' @noRd
910
check_package <- function(package) {
1011
msg_invalid <- glue::glue(

R/check_schema.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#' @param schema List object describing a Table Schema.
77
#' @param df A data frame against which the Table Schema must be compared.
88
#' @return `TRUE` or error.
9+
#' @family check functions
910
#' @noRd
1011
check_schema <- function(schema, df = NULL) {
1112
# Check schema is list with property fields

R/create_package.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#' Create an empty Data Package
22
#'
3-
#' Initiates a list object describing a
4-
#' [Data Package](https://specs.frictionlessdata.io/data-package/). This empty
5-
#' Data Package can then be extended with metadata and resources (see
3+
#' Initiates a list object describing a [Data
4+
#' Package](https://specs.frictionlessdata.io/data-package/).
5+
#' This empty Data Package can then be extended with metadata and resources (see
66
#' [add_resource()]).
77
#'
88
#' @return List object describing a Data Package.
9+
#' @family create functions
910
#' @export
1011
#' @examples
1112
#' # Create a Data Package

R/create_schema.R

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#'
77
#' @param df A data frame.
88
#' @return List object describing a Table Schema.
9+
#' @family create functions
910
#' @export
1011
#' @section Table schema properties:
1112
#' The Table Schema will be created from the data frame columns:
@@ -14,14 +15,15 @@
1415
#' - `title`: not set.
1516
#' - `description`: not set.
1617
#' - `type`: contains the converted column type (see further).
17-
#' - `format`: not set and can thus be considered `default`. This is also the
18-
#' case for dates, times and datetimes, since [readr::write_csv()] used by
19-
#' [write_package()] will format those to ISO8601 which is considered the
20-
#' default. Datetimes in local or non-UTC timezones will be converted to UTC
21-
#' before writing.
18+
#' - `format`: not set and can thus be considered `default`.
19+
#' This is also the case for dates, times and datetimes, since
20+
#' [readr::write_csv()] used by [write_package()] will format those to ISO8601
21+
#' which is considered the default.
22+
#' Datetimes in local or non-UTC timezones will be converted to UTC before
23+
#' writing.
2224
#' - `constraints`: not set, except for factors (see further).
23-
#' - `missingValues`: not set. [write_package()] will use the default `""` for
24-
#' missing values.
25+
#' - `missingValues`: not set.
26+
#' [write_package()] will use the default `""` for missing values.
2527
#' - `primaryKey`: not set.
2628
#' - `foreignKeys`: not set.
2729
#'
@@ -30,25 +32,25 @@
3032
#' The column type will determine the field `type`, as follows:
3133
#'
3234
#' - `character` →
33-
#' [string](https://specs.frictionlessdata.io/table-schema/#string).
35+
#' [string](https://specs.frictionlessdata.io/table-schema/#string).
3436
#' - `Date` → [date](https://specs.frictionlessdata.io/table-schema/#date).
3537
#' - `difftime` →
36-
#' [number](https://specs.frictionlessdata.io/table-schema/#number).
38+
#' [number](https://specs.frictionlessdata.io/table-schema/#number).
3739
#' - `factor` →
38-
#' [string](https://specs.frictionlessdata.io/table-schema/#string) with factor
39-
#' levels as `enum`.
40+
#' [string](https://specs.frictionlessdata.io/table-schema/#string) with
41+
#' factor levels as `enum`.
4042
#' - [hms::hms()] →
41-
#' [time](https://specs.frictionlessdata.io/table-schema/#time).
43+
#' [time](https://specs.frictionlessdata.io/table-schema/#time).
4244
#' - `integer` →
43-
#' [integer](https://specs.frictionlessdata.io/table-schema/#integer).
45+
#' [integer](https://specs.frictionlessdata.io/table-schema/#integer).
4446
#' - `logical` →.
45-
#' [boolean](https://specs.frictionlessdata.io/table-schema/#boolean).
47+
#' [boolean](https://specs.frictionlessdata.io/table-schema/#boolean).
4648
#' - `numeric` →
47-
#' [number](https://specs.frictionlessdata.io/table-schema/#number).
49+
#' [number](https://specs.frictionlessdata.io/table-schema/#number).
4850
#' - `POSIXct`/`POSIXlt` →
49-
#' [datetime](https://specs.frictionlessdata.io/table-schema/#datetime).
51+
#' [datetime](https://specs.frictionlessdata.io/table-schema/#datetime).
5052
#' - Any other type →
51-
#' [any](https://specs.frictionlessdata.io/table-schema/#any).
53+
#' [any](https://specs.frictionlessdata.io/table-schema/#any).
5254
#' @examples
5355
#' # Create a data frame
5456
#' df <- data.frame(

R/data.R

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
#' Example Data Package
22
#'
3-
#' Example Tabular
4-
#' [Data Package](https://specs.frictionlessdata.io/data-package/) with dummy
5-
#' camera trap data organized in 3 Data Resources:
3+
#' Example Tabular [Data
4+
#' Package](https://specs.frictionlessdata.io/data-package/) with dummy camera
5+
#' trap data organized in 3 Data Resources:
66
#' - `deployments`: data stored in `deployments.csv`.
77
#' - `observations`: data stored in `observations_1.csv` and
8-
#' `observations_2.csv`.
8+
#' `observations_2.csv`.
99
#' - `media`: data stored in `data` property.
1010
#'
11-
#' @source <https://github.com/frictionlessdata/frictionless-r/tree/main/inst/extdata>
11+
#' @source
12+
#' <https://github.com/frictionlessdata/frictionless-r/tree/main/inst/extdata>
1213
#' @examples
1314
#' \dontrun{
14-
#' # example_package.rda was created with the following code. Note that it must
15-
#' # be created using a URL, otherwise all Data Resource paths will point to
16-
#' # local paths that won't work for other users. One can load locally using:
17-
#' # read_package(system.file("extdata", "datapackage.json", package = "frictionless"))
15+
#' # example_package.rda was created with the following code.
16+
#' # Note that it must be created using a URL, otherwise all Data Resource paths
17+
#' # will point to local paths that won't work for other users.
18+
#' # One can load locally using:
19+
#' # read_package(
20+
#' # system.file("extdata", "datapackage.json", package = "frictionless")
21+
#' # )
1822
#' example_package <- read_package(file.path(
1923
#' "https://raw.githubusercontent.com/frictionlessdata/frictionless-r",
2024
#' "main/inst/extdata/datapackage.json"

R/get_resource.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
#'
66
#' @inheritParams read_resource
77
#' @return List object describing a Data Resource, with new property `read_from`
8-
#' to indicate how data should be read. If present, `path` will be updated to
9-
#' contain the full path(s).
8+
#' to indicate how data should be read.
9+
#' If present, `path` will be updated to contain the full path(s).
10+
#' @family edit functions
1011
#' @noRd
1112
#' @examples
1213
#' # Load the example Data Package

R/get_schema.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
#' Returns the [Table Schema](https://specs.frictionlessdata.io/table-schema/)
44
#' of a Data Resource (in a Data Package), i.e. the content of its `schema`
55
#' property, describing the resource's fields, data types, relationships, and
6-
#' missing values. The resource must be a
7-
#' [Tabular Data Resource](https://specs.frictionlessdata.io/tabular-data-resource/).
6+
#' missing values.
7+
#' The resource must be a [Tabular Data
8+
#' Resource](https://specs.frictionlessdata.io/tabular-data-resource/).
89
#'
910
#' @inheritParams read_resource
1011
#' @return List object describing a Table Schema.
12+
#' @family edit functions
1113
#' @export
1214
#' @examples
1315
#' # Load the example Data Package

0 commit comments

Comments
 (0)