When adding metadata properties as is shown in the examples in the package documentation, these items are indeed added to the newly made package, but they are not saved in datapackage.json when writing the package with write_package(). As a consequence, they are lost when reading the package again with read_package(). (The reprex shows the latter, I did not include the file datapackage.json here, but it shows the same information as the function read_package(), so the problem must occur in write_package().)
library(tidyverse)
library(frictionless)
#> Warning: package 'frictionless' was built under R version 4.3.3
# creating a package with metadata properties title and description
my_package <-
create_package() %>%
add_resource(
resource_name = "iris",
data = iris,
title = "Iris dataset", # Your additional metadata
description = "The built-in dataset in R."
)
# the package indeed includes the properties title and description
str(my_package)
#> List of 2
#> $ resources:List of 1
#> ..$ :List of 6
#> .. ..$ name : chr "iris"
#> .. ..$ data :'data.frame': 150 obs. of 5 variables:
#> .. .. ..$ Sepal.Length: num [1:150] 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
#> .. .. ..$ Sepal.Width : num [1:150] 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
#> .. .. ..$ Petal.Length: num [1:150] 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
#> .. .. ..$ Petal.Width : num [1:150] 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
#> .. .. ..$ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
#> .. ..$ profile : chr "tabular-data-resource"
#> .. ..$ schema :List of 1
#> .. .. ..$ fields:List of 5
#> .. .. .. ..$ :List of 2
#> .. .. .. .. ..$ name: chr "Sepal.Length"
#> .. .. .. .. ..$ type: chr "number"
#> .. .. .. ..$ :List of 2
#> .. .. .. .. ..$ name: chr "Sepal.Width"
#> .. .. .. .. ..$ type: chr "number"
#> .. .. .. ..$ :List of 2
#> .. .. .. .. ..$ name: chr "Petal.Length"
#> .. .. .. .. ..$ type: chr "number"
#> .. .. .. ..$ :List of 2
#> .. .. .. .. ..$ name: chr "Petal.Width"
#> .. .. .. .. ..$ type: chr "number"
#> .. .. .. ..$ :List of 3
#> .. .. .. .. ..$ name : chr "Species"
#> .. .. .. .. ..$ type : chr "string"
#> .. .. .. .. ..$ constraints:List of 1
#> .. .. .. .. .. ..$ enum: chr [1:3] "setosa" "versicolor" "virginica"
#> .. ..$ title : chr "Iris dataset"
#> .. ..$ description: chr "The built-in dataset in R."
#> $ directory: chr "."
#> - attr(*, "class")= chr [1:2] "datapackage" "list"
# writing the package
write_package(my_package, "irisdir")
# when reading the package again, title and description have disappeared
read_package("irisdir/datapackage.json")
#> Please make sure you have the right to access data from this Data Package for
#> your intended use.
#> Follow applicable norms or requirements to credit the dataset and its authors.
#> $resources
#> $resources[[1]]
#> $resources[[1]]$name
#> [1] "iris"
#>
#> $resources[[1]]$path
#> [1] "iris.csv"
#>
#> $resources[[1]]$profile
#> [1] "tabular-data-resource"
#>
#> $resources[[1]]$format
#> [1] "csv"
#>
#> $resources[[1]]$mediatype
#> [1] "text/csv"
#>
#> $resources[[1]]$encoding
#> [1] "utf-8"
#>
#> $resources[[1]]$schema
#> $resources[[1]]$schema$fields
#> $resources[[1]]$schema$fields[[1]]
#> $resources[[1]]$schema$fields[[1]]$name
#> [1] "Sepal.Length"
#>
#> $resources[[1]]$schema$fields[[1]]$type
#> [1] "number"
#>
#>
#> $resources[[1]]$schema$fields[[2]]
#> $resources[[1]]$schema$fields[[2]]$name
#> [1] "Sepal.Width"
#>
#> $resources[[1]]$schema$fields[[2]]$type
#> [1] "number"
#>
#>
#> $resources[[1]]$schema$fields[[3]]
#> $resources[[1]]$schema$fields[[3]]$name
#> [1] "Petal.Length"
#>
#> $resources[[1]]$schema$fields[[3]]$type
#> [1] "number"
#>
#>
#> $resources[[1]]$schema$fields[[4]]
#> $resources[[1]]$schema$fields[[4]]$name
#> [1] "Petal.Width"
#>
#> $resources[[1]]$schema$fields[[4]]$type
#> [1] "number"
#>
#>
#> $resources[[1]]$schema$fields[[5]]
#> $resources[[1]]$schema$fields[[5]]$name
#> [1] "Species"
#>
#> $resources[[1]]$schema$fields[[5]]$type
#> [1] "string"
#>
#> $resources[[1]]$schema$fields[[5]]$constraints
#> $resources[[1]]$schema$fields[[5]]$constraints$enum
#> [1] "setosa" "versicolor" "virginica"
#>
#>
#>
#>
#>
#>
#>
#> $directory
#> [1] "irisdir"
#>
#> attr(,"class")
#> [1] "datapackage" "list"
Created on 2024-03-25 with reprex v2.0.2
When adding metadata properties as is shown in the examples in the package documentation, these items are indeed added to the newly made package, but they are not saved in
datapackage.jsonwhen writing the package withwrite_package(). As a consequence, they are lost when reading the package again withread_package(). (The reprex shows the latter, I did not include the filedatapackage.jsonhere, but it shows the same information as the functionread_package(), so the problem must occur inwrite_package().)Created on 2024-03-25 with reprex v2.0.2