$schema should be the first property of package, resource, schema. That makes the JSON file easier to read.
- When creating an object from scratch, that is easy. Just define it first.
create_package(), create_schema and add_resource() already do this.
- When manipulating an object that already has properties, it's harder (i.e. what the
upgrade_ functions do). You need to use append() or alike.
The issue is that append() drops any custom attributes and class, which are required for functions that use that object.
library(frictionless)
p <- example_package()
attributes(p)
#> $names
#> [1] "name" "id" "licenses" "version" "created" "spatial"
#> [7] "temporal" "resources"
#>
#> $directory
#> [1] "/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/frictionless/extdata/v1"
#>
#> $class
#> [1] "datapackage" "list"
p <- append(p, list("$schema" = "just added"), after = 0)
attributes(p)
#> $names
#> [1] "$schema" "name" "id" "licenses" "version" "created"
#> [7] "spatial" "temporal" "resources"
Created on 2026-08-26 with reprex v2.1.1
TODO
$schemashould be the first property of package, resource, schema. That makes the JSON file easier to read.create_package(),create_schemaandadd_resource()already do this.upgrade_functions do). You need to useappend()or alike.The issue is that
append()drops any custom attributes and class, which are required for functions that use that object.Created on 2026-08-26 with reprex v2.1.1
TODO
purrr()? Note thatprepend()(deprecated) has the same issue.frictionlesshave its ownappend()function? See discussion atappend()drops customdatapackageclass #198