diff --git a/DESCRIPTION b/DESCRIPTION
index 8c2fadd5..13b2d255 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -38,6 +38,7 @@ Imports:
dplyr,
httr,
jsonlite,
+ lifecycle,
purrr,
readr (>= 2.1.0),
rlang,
@@ -50,7 +51,8 @@ Suggests:
rmarkdown,
stringi,
testthat (>= 3.0.0),
- tibble
+ tibble,
+ withr
VignetteBuilder: knitr
Config/testthat/edition: 3
Encoding: UTF-8
diff --git a/NAMESPACE b/NAMESPACE
index 2ac8d7b6..72e42a33 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -11,7 +11,9 @@ export(problems)
export(read_package)
export(read_resource)
export(remove_resource)
+export(resource_names)
export(resources)
+export(schema)
export(write_package)
import(rlang)
importFrom(readr,problems)
diff --git a/NEWS.md b/NEWS.md
index f053a6ed..a5c46f48 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,8 @@
# frictionless (development version)
+* `resources()` is soft-deprecated, please use `resource_names()` instead (#282).
+* `get_schema()` is soft-deprecated, please use `schema()` instead (#282).
+
# frictionless 1.2.1
* **frictionless now relies on R version 3.6.0 or higher**. Originally it stated version 3.5.0 or higher, but this was not tested and likely not true (#238).
diff --git a/R/add_resource.R b/R/add_resource.R
index 50a7c730..617dcb1c 100644
--- a/R/add_resource.R
+++ b/R/add_resource.R
@@ -45,7 +45,7 @@
#' package <- example_package()
#'
#' # List the resources
-#' resources(package)
+#' resource_names(package)
#'
#' # Create a data frame
#' df <- data.frame(
@@ -84,7 +84,7 @@
#' )
#'
#' # List the resources ("positions" and "positions_with_schema" added)
-#' resources(package)
+#' resource_names(package)
add_resource <- function(package, resource_name, data, schema = NULL,
replace = FALSE, delim = ",", ...) {
# Check package
@@ -111,7 +111,7 @@ add_resource <- function(package, resource_name, data, schema = NULL,
}
# Check resource does not exist yet for replace = FALSE
- if (!replace && resource_name %in% resources(package)) {
+ if (!replace && resource_name %in% resource_names(package)) {
cli::cli_abort(
c(
"{.arg package} already contains a resource named
@@ -206,7 +206,7 @@ add_resource <- function(package, resource_name, data, schema = NULL,
# Add CSV dialect for non-default delimiter or remove it
resource$dialect <- if (delim != ",") list(delimiter = delim) else NULL
- # Set attribute for get_resource()
+ # Set attribute for resource()
attr(resource, "path") <- "added"
}
diff --git a/R/deprecated.R b/R/deprecated.R
new file mode 100644
index 00000000..0606bc7b
--- /dev/null
+++ b/R/deprecated.R
@@ -0,0 +1,35 @@
+#' Deprecated functions
+#'
+#' @description
+#' `r lifecycle::badge("deprecated")`
+#'
+#' Use [schema()] instead of `get_schema()`.
+#'
+#' @family deprecated functions
+#' @export
+#' @keywords internal
+#' @name deprecated
+get_schema <- function(package, resource_name) {
+ lifecycle::deprecate_soft(
+ "1.3.0",
+ "get_schema()",
+ "schema()"
+ )
+ schema(package, resource_name)
+}
+
+#' @description
+#' Use [resource_names()] instead of `resources()`.
+#'
+#' @family deprecated functions
+#' @export
+#' @keywords internal
+#' @name deprecated
+resources <- function(package) {
+ lifecycle::deprecate_soft(
+ "1.3.0",
+ "resources()",
+ "resource_names()"
+ )
+ resource_names(package)
+}
diff --git a/R/locale.R b/R/locale.R
index efe57fd8..9f8cc1bb 100644
--- a/R/locale.R
+++ b/R/locale.R
@@ -9,10 +9,10 @@
#' @noRd
locale <- function(package, resource_name) {
# Get resource, includes check_package()
- resource <- get_resource(package, resource_name)
+ resource <- resource(package, resource_name)
# Get fields
- schema <- get_schema(package, resource_name)
+ schema <- schema(package, resource_name)
fields <- schema$fields
# Set decimal mark
diff --git a/R/print.R b/R/print.datapackage.R
similarity index 97%
rename from R/print.R
rename to R/print.datapackage.R
index 9e9fb757..f9bb35b7 100644
--- a/R/print.R
+++ b/R/print.datapackage.R
@@ -19,7 +19,7 @@ print.datapackage <- function(x, ...) {
# All prints should use cat (= cli::cat() helpers)
# List resources
- resource_names <- resources(x)
+ resource_names <- resource_names(x)
cli::cat_line(
cli::format_inline(
"A Data Package with {length(resource_names)} resource{?s}{?./:/:}"
diff --git a/R/read_from_path.R b/R/read_from_path.R
index 8c7c39fe..9dc55253 100644
--- a/R/read_from_path.R
+++ b/R/read_from_path.R
@@ -6,11 +6,11 @@
#' @noRd
read_from_path <- function(package, resource_name, col_select) {
# Get resource, includes check_package()
- resource <- get_resource(package, resource_name)
+ resource <- resource(package, resource_name)
# Get paths, schema and fields
paths <- resource$path
- schema <- get_schema(package, resource_name)
+ schema <- schema(package, resource_name)
fields <- schema$fields
field_names <- purrr::map_chr(fields, ~ purrr::pluck(.x, "name"))
diff --git a/R/read_resource.R b/R/read_resource.R
index a440bb4e..2aaab6c8 100644
--- a/R/read_resource.R
+++ b/R/read_resource.R
@@ -47,7 +47,7 @@
#' read_resource(package, "deployments", col_select = c("latitude", "longitude"))
read_resource <- function(package, resource_name, col_select = NULL) {
# Get resource, includes check_package()
- resource <- get_resource(package, resource_name)
+ resource <- resource(package, resource_name)
# Read data directly
if (resource$read_from == "df") {
diff --git a/R/remove_resource.R b/R/remove_resource.R
index ec8ada23..ef18a932 100644
--- a/R/remove_resource.R
+++ b/R/remove_resource.R
@@ -12,16 +12,16 @@
#' package <- example_package()
#'
#' # List the resources
-#' resources(package)
+#' resource_names(package)
#'
#' # Remove the resource "observations"
#' package <- remove_resource(package, "observations")
#'
#' # List the resources ("observations" removed)
-#' resources(package)
+#' resource_names(package)
remove_resource <- function(package, resource_name) {
# Check resource is present, includes check_package()
- resource <- get_resource(package, resource_name)
+ resource <- resource(package, resource_name)
# Remove resource
package$resources <- purrr::discard(package$resources, function(x) {
diff --git a/R/get_resource.R b/R/resource.R
similarity index 96%
rename from R/get_resource.R
rename to R/resource.R
index 2b64ad52..89ab98ce 100644
--- a/R/get_resource.R
+++ b/R/resource.R
@@ -9,12 +9,12 @@
#' If present, `path` will be updated to contain the full path(s).
#' @family accessor functions
#' @noRd
-get_resource <- function(package, resource_name) {
+resource <- function(package, resource_name) {
# Check package
check_package(package)
# Check resource
- resource_names <- resources(package)
+ resource_names <- resource_names(package)
if (!resource_name %in% resource_names) {
cli::cli_abort(
c(
diff --git a/R/resources.R b/R/resource_names.R
similarity index 77%
rename from R/resources.R
rename to R/resource_names.R
index b14c9d3d..15fbfea1 100644
--- a/R/resources.R
+++ b/R/resource_names.R
@@ -1,18 +1,18 @@
-#' List Data Resources
+#' List Data Resource names
#'
#' Lists the names of the Data Resources included in a Data Package.
#'
#' @inheritParams read_resource
#' @return Character vector with the Data Resource names.
-#' @family read functions
+#' @family accessor functions
#' @export
#' @examples
#' # Load the example Data Package
#' package <- example_package()
#'
#' # List the resources
-#' resources(package)
-resources <- function(package) {
+#' resource_names(package)
+resource_names <- function(package) {
# Check package (and that all resource have a name)
check_package(package)
diff --git a/R/get_schema.R b/R/schema.R
similarity index 90%
rename from R/get_schema.R
rename to R/schema.R
index 2cd3290d..e60efae9 100644
--- a/R/get_schema.R
+++ b/R/schema.R
@@ -17,11 +17,11 @@
#' package <- example_package()
#'
#' # Get the Table Schema for the resource "observations"
-#' schema <- get_schema(package, "observations")
+#' schema <- schema(package, "observations")
#' str(schema)
-get_schema <- function(package, resource_name) {
+schema <- function(package, resource_name) {
# Get resource
- resource <- get_resource(package, resource_name)
+ resource <- resource(package, resource_name)
# Check resource is tabular-data-resource (expected for resources with schema)
if (resource$profile %||% "" != "tabular-data-resource") {
diff --git a/R/write_resource.R b/R/write_resource.R
index 03634882..7d729ce2 100644
--- a/R/write_resource.R
+++ b/R/write_resource.R
@@ -11,7 +11,7 @@
write_resource <- function(package, resource_name, directory = ".",
compress = FALSE) {
# Get resource, includes check_package()
- resource <- get_resource(package, resource_name)
+ resource <- resource(package, resource_name)
# Resource contains new data
if (resource$read_from == "df") {
diff --git a/README.Rmd b/README.Rmd
index a915f594..e317a31e 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -69,7 +69,7 @@ package <- read_package("https://zenodo.org/records/10053702/files/datapackage.j
package
# List resources
-resources(package)
+resource_names(package)
# Read data from the resource "gps"
# This will return a single data frame, even though the data are split over
diff --git a/README.md b/README.md
index ed895e55..15887a2e 100644
--- a/README.md
+++ b/README.md
@@ -84,7 +84,7 @@ package
#> Use `unclass()` to print the Data Package as a list.
# List resources
-resources(package)
+resource_names(package)
#> [1] "reference-data" "gps" "acceleration"
# Read data from the resource "gps"
diff --git a/man/add_resource.Rd b/man/add_resource.Rd
index 9ad55a0b..2107a7da 100644
--- a/man/add_resource.Rd
+++ b/man/add_resource.Rd
@@ -71,7 +71,7 @@ Data Package standard.
package <- example_package()
# List the resources
-resources(package)
+resource_names(package)
# Create a data frame
df <- data.frame(
@@ -110,7 +110,7 @@ package <- add_resource(
)
# List the resources ("positions" and "positions_with_schema" added)
-resources(package)
+resource_names(package)
}
\seealso{
Other edit functions:
diff --git a/man/deprecated.Rd b/man/deprecated.Rd
new file mode 100644
index 00000000..24e4e204
--- /dev/null
+++ b/man/deprecated.Rd
@@ -0,0 +1,21 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/deprecated.R
+\name{deprecated}
+\alias{deprecated}
+\alias{get_schema}
+\alias{resources}
+\title{Deprecated functions}
+\usage{
+get_schema(package, resource_name)
+
+resources(package)
+}
+\description{
+\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
+
+Use \code{\link[=schema]{schema()}} instead of \code{get_schema()}.
+
+Use \code{\link[=resource_names]{resource_names()}} instead of \code{resources()}.
+}
+\concept{deprecated functions}
+\keyword{internal}
diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg
new file mode 100644
index 00000000..b61c57c3
--- /dev/null
+++ b/man/figures/lifecycle-deprecated.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg
new file mode 100644
index 00000000..5d88fc2c
--- /dev/null
+++ b/man/figures/lifecycle-experimental.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg
new file mode 100644
index 00000000..9bf21e76
--- /dev/null
+++ b/man/figures/lifecycle-stable.svg
@@ -0,0 +1,29 @@
+
diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg
new file mode 100644
index 00000000..db8d757f
--- /dev/null
+++ b/man/figures/lifecycle-superseded.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/print.datapackage.Rd b/man/print.datapackage.Rd
index d161bceb..8350468e 100644
--- a/man/print.datapackage.Rd
+++ b/man/print.datapackage.Rd
@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/print.R
+% Please edit documentation in R/print.datapackage.R
\name{print.datapackage}
\alias{print.datapackage}
\title{Print a Data Package}
diff --git a/man/read_package.Rd b/man/read_package.Rd
index 4f1bc582..098c9a3e 100644
--- a/man/read_package.Rd
+++ b/man/read_package.Rd
@@ -34,7 +34,6 @@ package$created
}
\seealso{
Other read functions:
-\code{\link{read_resource}()},
-\code{\link{resources}()}
+\code{\link{read_resource}()}
}
\concept{read functions}
diff --git a/man/read_resource.Rd b/man/read_resource.Rd
index 0cf8c4fb..55154003 100644
--- a/man/read_resource.Rd
+++ b/man/read_resource.Rd
@@ -59,7 +59,6 @@ read_resource(package, "deployments", col_select = c("latitude", "longitude"))
}
\seealso{
Other read functions:
-\code{\link{read_package}()},
-\code{\link{resources}()}
+\code{\link{read_package}()}
}
\concept{read functions}
diff --git a/man/remove_resource.Rd b/man/remove_resource.Rd
index d225f261..067ae16b 100644
--- a/man/remove_resource.Rd
+++ b/man/remove_resource.Rd
@@ -24,13 +24,13 @@ described \code{resources}.
package <- example_package()
# List the resources
-resources(package)
+resource_names(package)
# Remove the resource "observations"
package <- remove_resource(package, "observations")
# List the resources ("observations" removed)
-resources(package)
+resource_names(package)
}
\seealso{
Other edit functions:
diff --git a/man/resources.Rd b/man/resource_names.Rd
similarity index 64%
rename from man/resources.Rd
rename to man/resource_names.Rd
index ab6b0e86..aa68deac 100644
--- a/man/resources.Rd
+++ b/man/resource_names.Rd
@@ -1,10 +1,10 @@
% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/resources.R
-\name{resources}
-\alias{resources}
-\title{List Data Resources}
+% Please edit documentation in R/resource_names.R
+\name{resource_names}
+\alias{resource_names}
+\title{List Data Resource names}
\usage{
-resources(package)
+resource_names(package)
}
\arguments{
\item{package}{Data Package object, as returned by \code{\link[=read_package]{read_package()}} or
@@ -21,11 +21,10 @@ Lists the names of the Data Resources included in a Data Package.
package <- example_package()
# List the resources
-resources(package)
+resource_names(package)
}
\seealso{
-Other read functions:
-\code{\link{read_package}()},
-\code{\link{read_resource}()}
+Other accessor functions:
+\code{\link{schema}()}
}
-\concept{read functions}
+\concept{accessor functions}
diff --git a/man/get_schema.Rd b/man/schema.Rd
similarity index 81%
rename from man/get_schema.Rd
rename to man/schema.Rd
index 4d9624bb..44d4d059 100644
--- a/man/get_schema.Rd
+++ b/man/schema.Rd
@@ -1,10 +1,10 @@
% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/get_schema.R
-\name{get_schema}
-\alias{get_schema}
+% Please edit documentation in R/schema.R
+\name{schema}
+\alias{schema}
\title{Get the Table Schema of a Data Resource}
\usage{
-get_schema(package, resource_name)
+schema(package, resource_name)
}
\arguments{
\item{package}{Data Package object, as returned by \code{\link[=read_package]{read_package()}} or
@@ -29,7 +29,11 @@ See \code{vignette("table-schema")} to learn more about Table Schema.
package <- example_package()
# Get the Table Schema for the resource "observations"
-schema <- get_schema(package, "observations")
+schema <- schema(package, "observations")
str(schema)
}
+\seealso{
+Other accessor functions:
+\code{\link{resource_names}()}
+}
\concept{accessor functions}
diff --git a/tests/testthat/test-add_resource.R b/tests/testthat/test-add_resource.R
index df914609..53158ae5 100644
--- a/tests/testthat/test-add_resource.R
+++ b/tests/testthat/test-add_resource.R
@@ -250,7 +250,7 @@ test_that("add_resource() adds resource", {
expect_identical(p$resources[[4]][["profile"]], "tabular-data-resource")
expect_identical(p$resources[[4]][["data"]], df)
expect_identical(
- resources(p),
+ resource_names(p),
c("deployments", "observations", "media", "new_df")
)
@@ -261,7 +261,7 @@ test_that("add_resource() adds resource", {
expect_identical(p$resources[[5]][["profile"]], "tabular-data-resource")
expect_null(p$resources[[5]][["data"]])
expect_identical(
- resources(p),
+ resource_names(p),
c("deployments", "observations", "media", "new_df", "new_csv")
)
})
@@ -273,7 +273,7 @@ test_that("add_resource() can replace an existing resource", {
add_resource(p, "deployments", df, replace = TRUE)
)
p_replaced <- add_resource(p, "deployments", df, replace = TRUE)
- expect_equal(resources(p), resources(p_replaced))
+ expect_equal(resource_names(p), resource_names(p_replaced))
})
test_that("add_resource() uses provided schema (list or path) or creates one", {
@@ -294,9 +294,9 @@ test_that("add_resource() uses provided schema (list or path) or creates one", {
expect_identical(p$resources[[1]]$schema, schema)
expect_identical(p$resources[[2]]$schema, schema_custom)
expect_identical(p$resources[[3]]$schema, schema_custom)
- expect_identical(get_schema(p, "new_df"), schema)
- expect_identical(get_schema(p, "new_df_with_list_schema"), schema_custom)
- expect_identical(get_schema(p, "new_df_with_file_schema"), schema_custom)
+ expect_identical(schema(p, "new_df"), schema)
+ expect_identical(schema(p, "new_df_with_list_schema"), schema_custom)
+ expect_identical(schema(p, "new_df_with_file_schema"), schema_custom)
# csv
p <- add_resource(p, "new_csv", df)
@@ -305,9 +305,9 @@ test_that("add_resource() uses provided schema (list or path) or creates one", {
expect_identical(p$resources[[4]]$schema, schema)
expect_identical(p$resources[[5]]$schema, schema_custom)
expect_identical(p$resources[[6]]$schema, schema_custom)
- expect_identical(get_schema(p, "new_csv"), schema)
- expect_identical(get_schema(p, "new_csv_with_list_schema"), schema_custom)
- expect_identical(get_schema(p, "new_csv_with_file_schema"), schema_custom)
+ expect_identical(schema(p, "new_csv"), schema)
+ expect_identical(schema(p, "new_csv_with_list_schema"), schema_custom)
+ expect_identical(schema(p, "new_csv_with_file_schema"), schema_custom)
})
test_that("add_resource() can add resource from data frame, readable by
@@ -322,7 +322,7 @@ test_that("add_resource() can add resource from local, relative, absolute,
remote or compressed CSV file, readable by read_resource()", {
skip_if_offline()
p <- example_package()
- schema <- get_schema(p, "deployments")
+ schema <- schema(p, "deployments")
# Local
local_path <- "data/df.csv"
diff --git a/tests/testthat/test-check_schema.R b/tests/testthat/test-check_schema.R
index 0ef7498b..5cfeaa44 100644
--- a/tests/testthat/test-check_schema.R
+++ b/tests/testthat/test-check_schema.R
@@ -2,13 +2,13 @@ test_that("check_schema() returns schema invisibly on valid Table Schema", {
p <- example_package()
# Can't obtain df using read_resource(), because that function uses
- # check_schema() (in get_schema()) internally, which is what we want to test
+ # check_schema() (in schema()) internally, which is what we want to test
df <- suppressMessages(
readr::read_csv(file.path(p$directory, p$resources[[1]]$path))
)
- # Using get_schema()
- schema_get <- get_schema(p, "deployments")
+ # Using schema()
+ schema_get <- schema(p, "deployments")
expect_identical(check_schema(schema_get), schema_get)
expect_invisible(check_schema(schema_get))
expect_identical(check_schema(schema_get, df), schema_get)
diff --git a/tests/testthat/test-deprecated.R b/tests/testthat/test-deprecated.R
new file mode 100644
index 00000000..4393d3cc
--- /dev/null
+++ b/tests/testthat/test-deprecated.R
@@ -0,0 +1,27 @@
+test_that("get_schema() shows deprecation warning", {
+ p <- example_package()
+ lifecycle::expect_deprecated(get_schema(p, "deployments"))
+})
+
+test_that("get_schema() forwards to schema()", {
+ withr::local_options(lifecycle_verbosity = "quiet")
+ p <- example_package()
+ expect_identical(
+ get_schema(p, "deployments"),
+ schema(p, "deployments")
+ )
+})
+
+test_that("resources() shows deprecation warning", {
+ p <- example_package()
+ lifecycle::expect_deprecated(resources(p))
+})
+
+test_that("resources() forwards to resource_names()", {
+ withr::local_options(lifecycle_verbosity = "quiet")
+ p <- example_package()
+ expect_identical(
+ resources(p),
+ resource_names(p)
+ )
+})
diff --git a/tests/testthat/test-print.R b/tests/testthat/test-print.datapackage.R
similarity index 88%
rename from tests/testthat/test-print.R
rename to tests/testthat/test-print.datapackage.R
index ab1eab0a..2ca98a12 100644
--- a/tests/testthat/test-print.R
+++ b/tests/testthat/test-print.datapackage.R
@@ -1,9 +1,9 @@
-test_that("print() returns output invisibly", {
+test_that("print.datapackage() returns output invisibly", {
expect_output(output <- withVisible(print(example_package())))
expect_false(output$visible)
})
-test_that("print() informs about the resources and unclass()", {
+test_that("print.datapackage() informs about the resources and unclass()", {
unclass_message <- "Use `unclass()` to print the Data Package as a list."
# 3 resources (example package)
@@ -49,7 +49,7 @@ test_that("print() informs about the resources and unclass()", {
)
})
-test_that("print() informs about information in package$id", {
+test_that("print.datapackage() informs about information in package$id", {
unclass_message <- "Use `unclass()` to print the Data Package as a list."
# package$id is a URL, inform
diff --git a/tests/testthat/test-read_package.R b/tests/testthat/test-read_package.R
index 072dee83..5c6a1951 100644
--- a/tests/testthat/test-read_package.R
+++ b/tests/testthat/test-read_package.R
@@ -11,8 +11,8 @@ test_that("read_package() returns a valid Data Package reading from path", {
# Package has correct resources
resource_names <- c("deployments", "observations", "media")
- expect_identical(resources(p_local), resource_names)
- expect_identical(resources(p_minimal), resource_names)
+ expect_identical(resource_names(p_local), resource_names)
+ expect_identical(resource_names(p_minimal), resource_names)
# Package has correct "directory", containing root dir of datapackage.json
expect_identical(
@@ -36,7 +36,7 @@ test_that("read_package() returns a valid Data Package reading from url", {
# Package has correct resources
resource_names <- c("deployments", "observations", "media")
- expect_identical(resources(p_remote), resource_names)
+ expect_identical(resource_names(p_remote), resource_names)
# Package has correct "directory", containing root dir of datapackage.json
expect_identical(
diff --git a/tests/testthat/test-resources.R b/tests/testthat/test-resource_names.R
similarity index 50%
rename from tests/testthat/test-resources.R
rename to tests/testthat/test-resource_names.R
index ff13f9fa..4a34ba07 100644
--- a/tests/testthat/test-resources.R
+++ b/tests/testthat/test-resource_names.R
@@ -1,22 +1,22 @@
-test_that("resources() returns a character vector of resource names", {
+test_that("resource_names() returns a character vector of resource names", {
p <- example_package()
- expect_identical(resources(p), c("deployments", "observations", "media"))
+ expect_identical(resource_names(p), c("deployments", "observations", "media"))
# 1 resource
p <- remove_resource(p, "media")
p <- remove_resource(p, "observations")
- expect_identical(resources(p), c("deployments"))
+ expect_identical(resource_names(p), c("deployments"))
# 0 resources
p <- remove_resource(p, "deployments")
- expect_identical(resources(p), character(0))
+ expect_identical(resource_names(p), character(0))
})
-test_that("resources() returns error if resources have no name", {
+test_that("resource_names() returns error if resources have no name", {
p <- example_package()
p$resources[[2]]$name <- NULL
expect_error(
- resources(p),
+ resource_names(p),
class = "frictionless_error_resources_without_name"
)
diff --git a/vignettes/data-package.Rmd b/vignettes/data-package.Rmd
index cae0d394..5f054268 100644
--- a/vignettes/data-package.Rmd
+++ b/vignettes/data-package.Rmd
@@ -93,7 +93,7 @@ my_package
### resources
-[`resources`](https://specs.frictionlessdata.io/data-package/#resource-information) is required. It is used by `resources()` and many other functions. `check_package()` returns an error if it is missing.
+[`resources`](https://specs.frictionlessdata.io/data-package/#resource-information) is required. It is used by `resource_names()` and many other functions. `check_package()` returns an error if it is missing.
diff --git a/vignettes/data-resource.Rmd b/vignettes/data-resource.Rmd
index bd176dd7..dada334d 100644
--- a/vignettes/data-resource.Rmd
+++ b/vignettes/data-resource.Rmd
@@ -27,14 +27,14 @@ Frictionless supports reading, manipulating and writing resources, but much of i
### Read
-`resources()` lists all resources in a package:
+`resource_names()` lists all resources in a package:
```{r}
library(frictionless)
package <- example_package()
# List the resources
-resources(package)
+resource_names(package)
```
`read_resource()` reads data from a tabular resource to a data frame:
diff --git a/vignettes/frictionless.Rmd b/vignettes/frictionless.Rmd
index f1e9f981..f291f943 100644
--- a/vignettes/frictionless.Rmd
+++ b/vignettes/frictionless.Rmd
@@ -71,11 +71,11 @@ str(package, list.len = 3)
#> - attr(*, "class")= chr [1:2] "datapackage" "list"
```
-The most important aspect of a Data Package are its **Data Resources**, which describe and point to the data. You can list all included resources with `resources()`:
+The most important aspect of a Data Package are its **Data Resources**, which describe and point to the data. You can list all included resources with `resource_names()`:
``` r
-resources(package)
+resource_names(package)
#> [1] "reference-data" "gps" "acceleration"
```
@@ -187,13 +187,13 @@ my_package
#> Use `unclass()` to print the Data Package as a list.
```
-By default, `add_resource()` will create a **Table Schema** for your data frame, describing its field names, field types and (for factors) constraints. You can retrieve the schema of a resource with `get_schema()`. It is a list, which we print here using `str()`:
+By default, `add_resource()` will create a **Table Schema** for your data frame, describing its field names, field types and (for factors) constraints. You can retrieve the schema of a resource with `schema()`. It is a list, which we print here using `str()`:
``` r
iris_schema <-
my_package %>%
- get_schema("iris")
+ schema("iris")
str(iris_schema)
#> List of 1
diff --git a/vignettes/frictionless.Rmd.orig b/vignettes/frictionless.Rmd.orig
index 5e0c4a2f..ddfcbbf5 100644
--- a/vignettes/frictionless.Rmd.orig
+++ b/vignettes/frictionless.Rmd.orig
@@ -45,10 +45,10 @@ Since a Data Package is a list, you can pass it to functions that work on lists,
str(package, list.len = 3)
```
-The most important aspect of a Data Package are its **Data Resources**, which describe and point to the data. You can list all included resources with `resources()`:
+The most important aspect of a Data Package are its **Data Resources**, which describe and point to the data. You can list all included resources with `resource_names()`:
```{r}
-resources(package)
+resource_names(package)
```
This Data Package has 3 resources. Let's read the data from the `gps` resource into a data frame:
@@ -106,12 +106,12 @@ You can chain most frictionless functions together using pipes (`%>%` or `|>`),
my_package
```
-By default, `add_resource()` will create a **Table Schema** for your data frame, describing its field names, field types and (for factors) constraints. You can retrieve the schema of a resource with `get_schema()`. It is a list, which we print here using `str()`:
+By default, `add_resource()` will create a **Table Schema** for your data frame, describing its field names, field types and (for factors) constraints. You can retrieve the schema of a resource with `schema()`. It is a list, which we print here using `str()`:
```{r}
iris_schema <-
my_package %>%
- get_schema("iris")
+ schema("iris")
str(iris_schema)
```
diff --git a/vignettes/table-schema.Rmd b/vignettes/table-schema.Rmd
index c8165e70..c6f6dc9d 100644
--- a/vignettes/table-schema.Rmd
+++ b/vignettes/table-schema.Rmd
@@ -27,14 +27,14 @@ Frictionless supports `schema$fields` and `schema$missingValues` to parse data t
### Read
-`get_schema()` extracts the schema from a resource:
+`schema()` extracts the schema from a resource:
```{r}
library(frictionless)
package <- example_package()
# Get the Table Schema for the resource "observations"
-schema <- get_schema(package, "observations")
+schema <- schema(package, "observations")
str(schema)
```
@@ -66,7 +66,7 @@ levels(observations$life_stage)
### Manipulate
-A schema is a list which you can manipulate, but frictionless does not provide functions to do that. Use `{purrr}` or base R instead (see `vignette("frictionless")`). You do not have to start a schema from scratch though: use `get_schema()` (see above) or `create_schema()` instead.
+A schema is a list which you can manipulate, but frictionless does not provide functions to do that. Use `{purrr}` or base R instead (see `vignette("frictionless")`). You do not have to start a schema from scratch though: use `schema()` (see above) or `create_schema()` instead.
`create_schema()` creates a schema from a data frame and defines the `name`, `type` (and if a factor `constraints$enum`) for each field: