{"id":13857576,"url":"https://github.com/frictionlessdata/datapackage-r","last_synced_at":"2026-03-04T15:31:48.848Z","repository":{"id":46060493,"uuid":"91328597","full_name":"frictionlessdata/datapackage-r","owner":"frictionlessdata","description":"An R package for working with Data Package.","archived":false,"fork":false,"pushed_at":"2021-12-22T11:47:11.000Z","size":984,"stargazers_count":42,"open_issues_count":3,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-04T01:27:08.061Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://frictionlessdata.github.io/datapackage-r/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frictionlessdata.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-15T11:08:18.000Z","updated_at":"2025-08-12T04:29:30.000Z","dependencies_parsed_at":"2022-09-18T00:00:28.922Z","dependency_job_id":null,"html_url":"https://github.com/frictionlessdata/datapackage-r","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/frictionlessdata/datapackage-r","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frictionlessdata%2Fdatapackage-r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frictionlessdata%2Fdatapackage-r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frictionlessdata%2Fdatapackage-r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frictionlessdata%2Fdatapackage-r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frictionlessdata","download_url":"https://codeload.github.com/frictionlessdata/datapackage-r/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frictionlessdata%2Fdatapackage-r/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30084967,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T13:22:36.021Z","status":"ssl_error","status_checked_at":"2026-03-04T13:20:45.750Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-05T03:01:41.000Z","updated_at":"2026-03-04T15:31:48.824Z","avatar_url":"https://github.com/frictionlessdata.png","language":"R","readme":"---\ntitle: \u003cimg src=\"okgr.png\" align=\"right\" width=100px /\u003e\u003cimg src=\"oklabs.png\" align=\"right\" width=100px /\u003e\u003cbr\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cimg src=\"Ffrictionless.png\" align=\"left\" width=120 /\u003e\u003cbr/\u003erictionless Data - \u003cbr/\u003eData Package\noutput: \n  github_document:\n    html_preview: no \n  number_sections: yes\n---\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/datapackage.r)](https://cran.r-project.org/package=datapackage.r)\n[![R-CMD-check](https://github.com/frictionlessdata/datapackage-r/workflows/R-CMD-check/badge.svg)](https://github.com/frictionlessdata/datapackage-r/actions)\n[![Coverage Status](https://coveralls.io/repos/github/frictionlessdata/datapackage-r/badge.svg?branch=master)](https://coveralls.io/github/frictionlessdata/datapackage-r?branch=master)\n[![Project Status: Active – The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)\n[![Rdoc](http://www.rdocumentation.org/badges/version/datapackage.r)](http://www.rdocumentation.org/packages/datapackage.r)\n[![](http://cranlogs.r-pkg.org/badges/grand-total/datapackage.r)](http://cran.rstudio.com/web/packages/datapackage.r/index.html)\n[![Licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![Support](https://img.shields.io/badge/support-discord-brightgreen)](https://discordapp.com/invite/Sewv6av)\n\n\n# Description\n\n\nR package for working with [Frictionless Data Package][datapackage].\n\n## Features\n\n- `Package` class for working with data packages\n- `Resource` class for working with data resources\n- `Profile` class for working with profiles\n- `validate` function for validating data package descriptors\n- `infer` function for inferring data package descriptors\n\n# Getting started\n\n## Installation\n\nIn order to install the latest distribution of [R software][Rs] to your computer you have to select one of the mirror sites of the [Comprehensive R Archive Network][R], select the appropriate link for your operating system and follow the wizard instructions.\n\nFor windows users you can:\n\n1. Go to CRAN\n2. Click download R for Windows\n3. Click Base (This is what you want to install R for the first time)\n4. Download the latest R version\n5. Run installation file and follow the instrustions of the installer.\n\n(Mac) OS X and Linux users may need to follow different steps depending on their system version to install R successfully and it is recommended to read the instructions on CRAN site carefully.\n\nEven more detailed installation instructions can be found in [R Installation and Administration manual][Rman].\n\nTo install [RStudio][Rstudio], you can download [RStudio Desktop][Rstudiodown] with Open Source License and follow the wizard instructions:\n\n1. Go to [RStudio](https://www.rstudio.com/products/rstudio/)\n2. Click download on RStudio Desktop \n3. Download on RStudio Desktop free download\n4. Select the appropriate file for your system\n5. Run installation file\n\nTo install the `datapackage` package it is necessary to install first [devtools package](https://cran.r-project.org/package=devtools) to make installation of github packages available.\n\n```{r, eval=FALSE, include=TRUE}\n# Install devtools package if not already\ninstall.packages(\"devtools\")\n```\n\n\nInstall `datapackage.r`\n\n```{r, eval=FALSE, include=T}\n# And then install the development version from github\ndevtools::install_github(\"frictionlessdata/datapackage-r\")\n```\n\n## Load package\n```{r, echo=TRUE}\n# load the package using\nlibrary(datapackage.r)\n```\n\n# Examples\n\nCode examples in this readme requires R 3.3 or higher, You could see even more [examples](https://github.com/frictionlessdata/datapackage-r/tree/master/vignettes) in vignettes directory. \n\n```{r eval=TRUE, include=TRUE, warning=FALSE}\ndescriptor \u003c- '{\n  \"resources\": [\n    {\n      \"name\": \"example\",\n      \"profile\": \"tabular-data-resource\",\n      \"data\": [\n        [\"height\", \"age\", \"name\"],\n        [180, 18, \"Tony\"],\n        [192, 32, \"Jacob\"]\n      ],\n      \"schema\":  {\n        \"fields\": [\n          {\"name\": \"height\", \"type\": \"integer\" },\n          {\"name\": \"age\", \"type\": \"integer\" },\n          {\"name\": \"name\", \"type\": \"string\" }\n        ]\n      }\n    }\n  ]\n}'\n\ndataPackage \u003c- Package.load(descriptor)\ndataPackage\n```\n\n```{r eval=TRUE, include=TRUE, warning=FALSE}\nresource \u003c- dataPackage$getResource('example')\n# convert to json and add indentation with jsonlite prettify function\njsonlite::prettify(helpers.from.list.to.json(resource$read()))\n```\n\n\n# Documentation\n\nJson objects are not included in R base data types. [Jsonlite package](https://CRAN.R-project.org/package=jsonlite) is internally used to convert json data to list objects. The input parameters of functions could be json strings, files or lists and the outputs are in list format to easily further process your data in R environment and exported as desired. The examples below show how to use jsonlite package to convert the output back to json adding indentation whitespace. More details about handling json you can see jsonlite documentation or vignettes [here](https://CRAN.R-project.org/package=jsonlite).\n\n## Working with Package\n\nA class for working with data packages. It provides various capabilities like loading local or remote data package, inferring a data package descriptor, saving a data package descriptor and many more.\n\nConsider we have some local `csv` files in a `data` directory. Let's create a data package based on this data using a `Package` class:\n\n\u003e inst/extdata/readme_example/cities.csv\n\n\n```csv\ncity,location\nlondon,\"51.50,-0.11\"\nparis,\"48.85,2.30\"\nrome,\"41.89,12.51\"\n```\n\u003e inst/extdata/readme_example/population.csv\n\n```csv\ncity,year,population\nlondon,2017,8780000\nparis,2017,2240000\nrome,2017,2860000\n```\n\n```{r \"setup\", include=FALSE}\nrequire(\"knitr\")\nopts_knit$set(root.dir = \"inst/extdata/readme_example/\")\n```\n\nFirst we create a blank data package:\n\n```{r eval=TRUE, include=TRUE, echo=TRUE}\ndataPackage \u003c- Package.load()\n```\n\nNow we're ready to infer a data package descriptor based on data files we have. Because we have two csv files we use glob pattern `csv`:\n\n```{r eval=TRUE, include=TRUE, warning=FALSE, message=FALSE}\njsonlite::toJSON(dataPackage$infer('csv'), pretty = TRUE)\n```\n\n```{r eval=TRUE, include=TRUE, warning=FALSE, message=FALSE}\njsonlite::toJSON(dataPackage$descriptor, pretty = TRUE)\n```\n\n\nAn `infer` method has found all our files and inspected it to extract useful metadata like profile, encoding, format, Table Schema etc. Let's tweak it a little bit:\n\n```{r eval=TRUE, include=TRUE}\ndataPackage$descriptor$resources[[2]]$schema$fields[[2]]$type \u003c- 'year'\ndataPackage$commit()\ndataPackage$valid\n```\n\nBecause our resources are tabular we could read it as a tabular data:\n\n```{r eval=TRUE, include=TRUE}\njsonlite::toJSON(dataPackage$getResource(\"population\")$read(keyed = TRUE),auto_unbox = FALSE,pretty = TRUE)\n```\n\nLet's save our descriptor on the disk. After it we could update our `datapackage.json` as we want, make some changes etc:\n\n```{r eval=FALSE, include=TRUE}\ndataPackage.save('datapackage.json')\n```\n\nTo continue the work with the data package we just load it again but this time using local `datapackage.json`:\n\n```{r eval=FALSE, include=TRUE}\ndataPackage \u003c- Package.load('datapackage.json')\n# Continue the work\n```\n\nIt was one basic introduction to the `Package` class. To learn more let's take a look on `Package` class API reference.\n\n\n### Resource\n\nA class for working with data resources. You can read or iterate tabular resources using the `iter/read` methods and all resource as bytes using `rowIter/rowRead` methods.\n\nConsider we have some local csv file. It could be inline data or remote link - all supported by `Resource` class (except local files for in-brower usage of course). But say it's `cities.csv` for now:\n\n```csv\ncity,location\nlondon,\"51.50,-0.11\"\nparis,\"48.85,2.30\"\nrome,N/A\n```\n\nLet's create and read a resource. We use static `Resource$load` method instantiate a resource. Because resource is tabular we could use `resourceread` method with a `keyed` option to get an list of keyed rows:\n\n```{r eval=TRUE, include=TRUE}\nresource \u003c- Resource.load('{\"path\": \"cities.csv\"}')\nresource$tabular\n```\n\n```{r eval=TRUE, include=TRUE}\njsonlite::toJSON(resource$read(keyed = TRUE), pretty = TRUE)\n```\n\nAs we could see our locations are just a strings. But it should be geopoints. Also Rome's location is not available but it's also just a `N/A` string instead of `null`. First we have to infer resource metadata:\n\n```{r eval=TRUE, include=TRUE}\njsonlite::toJSON(resource$infer(), pretty = TRUE)\n```\n\n```{r eval=TRUE, include=TRUE}\njsonlite::toJSON(resource$descriptor, pretty = TRUE)\n# resource$read( keyed = TRUE )\n# # Fails with a data validation error\n```\n\nLet's fix not available location. There is a `missingValues` property in Table Schema specification. As a first try we set `missingValues` to `N/A` in `resource$descriptor.schema`. Resource descriptor could be changed in-place but all changes should be commited by `resource$commit()`:\n\n```{r eval=TRUE, include=TRUE}\nresource$descriptor$schema$missingValues \u003c- 'N/A'\nresource$commit()\n```\n\n```{r eval=TRUE, include=TRUE}\nresource$valid # FALSE\nresource$errors\n```\n\nAs a good citiziens we've decided to check out recource descriptor validity. And it's not valid! We should use an list for `missingValues` property. Also don't forget to have an empty string as a missing value:\n\n```{r eval=TRUE, include=TRUE}\nresource$descriptor$schema[['missingValues']] \u003c- list('', 'N/A')\nresource$commit()\nresource$valid # TRUE\n```\n\nAll good. It looks like we're ready to read our data again:\n\n```{r eval=TRUE, include=TRUE}\njsonlite::toJSON(resource$read( keyed = TRUE ), pretty = TRUE)\n```\n\n\nNow we see that:\n- locations are lists with numeric lattide and longitude\n- Rome's location is a native JavaScript `null`\n\nAnd because there are no errors on data reading we could be sure that our data is valid againt our schema. Let's save our resource descriptor:\n\n```{r eval=FALSE, include=TRUE}\nresource$save('dataresource.json')\n```\n\nLet's check newly-crated `dataresource.json`. It contains path to our data file, inferred metadata and our `missingValues` tweak:\n\n```json\n{\n\"path\": \"data.csv\",\n\"profile\": \"tabular-data-resource\",\n\"encoding\": \"utf-8\",\n\"name\": \"data\",\n\"format\": \"csv\",\n\"mediatype\": \"text/csv\",\n\"schema\": {\n\"fields\": [\n{\n\"name\": \"city\",\n\"type\": \"string\",\n\"format\": \"default\"\n},\n{\n\"name\": \"location\",\n\"type\": \"geopoint\",\n\"format\": \"default\"\n}\n],\n\"missingValues\": [\n\"\",\n\"N/A\"\n]\n}\n}\n```\n\nIf we decide to improve it even more we could update the `dataresource.json` file and then open it again using local file name:\n\n```{r eval=FALSE, include=TRUE}\nresource \u003c- Resource.load('dataresource.json')\n# Continue the work\n```\n\nIt was one basic introduction to the `Resource` class. To learn more let's take a look on `Resource` class API reference.\n\n### Working with Profile\n\nA component to represent JSON Schema profile from [Profiles Registry](https://specs.frictionlessdata.io/schemas/registry.json):\n\n```{r eval=TRUE, include=TRUE}\nprofile \u003c- Profile.load('data-package')\nprofile$name # data-package\n```\n\n```{r eval=FALSE, include=TRUE}\nprofile$jsonschema # List of JSON Schema contents\n```\n\n```{r eval=TRUE, include=TRUE}\nvalid_errors \u003c- profile$validate(descriptor)\nvalid \u003c- valid_errors$valid # TRUE if valid descriptor\nvalid\n```\n\n### Working with validate\n\nA standalone function to validate a data package descriptor:\n\n```{r eval=FALSE, include=TRUE}\nvalid_errors \u003c- validate('{\"name\": \"Invalid Datapackage\"}')\n```\n\n### Working with infer\n\nA standalone function to infer a data package descriptor.\n\n```{r eval=TRUE, include=TRUE}\ndescriptor \u003c- infer(\"csv\",basePath = '.')\njsonlite::toJSON(descriptor, pretty = TRUE)\n```\n\n### Working with Foreign Keys\n\nThe package supports foreign keys described in the [Table Schema](https://specs.frictionlessdata.io/table-schema/#foreign-keys) specification. It means if your data package descriptor use `resources[]$schema$foreignKeys` property for some resources a data integrity will be checked on reading operations.\n\nConsider we have a data package:\n\n```{r eval=TRUE, include=TRUE}\nDESCRIPTOR \u003c- '{\n\"resources\": [\n{\n\"name\": \"teams\",\n\"data\": [\n[\"id\", \"name\", \"city\"],\n[\"1\", \"Arsenal\", \"London\"],\n[\"2\", \"Real\", \"Madrid\"],\n[\"3\", \"Bayern\", \"Munich\"]\n],\n\"schema\": {\n\"fields\": [\n{\"name\": \"id\", \"type\": \"integer\"},\n{\"name\": \"name\", \"type\": \"string\"},\n{\"name\": \"city\", \"type\": \"string\"}\n],\n\"foreignKeys\": [\n{\n\"fields\": \"city\",\n\"reference\": {\"resource\": \"cities\", \"fields\": \"name\"}\n}\n]\n}\n}, {\n\"name\": \"cities\",\n\"data\": [\n[\"name\", \"country\"],\n[\"London\", \"England\"],\n[\"Madrid\", \"Spain\"]\n]\n}\n]\n}'\n```\n\nLet's check relations for a `teams` resource:\n\n```{r eval=TRUE, include=TRUE, warning=FALSE}\npackage \u003c- Package.load(DESCRIPTOR)\nteams \u003c- package$getResource('teams')\n```\n\n```{r eval=TRUE, include=TRUE,warning=FALSE, error=TRUE}\nteams$checkRelations()\n# tableschema.exceptions.RelationError: Foreign key \"['city']\" violation in row \"4\"\n```\n\nAs we could see there is a foreign key violation. That's because our lookup table `cities` doesn't have a city of `Munich` but we have a team from there. We need to fix it in `cities` resource:\n\n```{r eval=TRUE, include=TRUE}\npackage$descriptor$resources[[2]]$data \u003c- rlist::list.append(package$descriptor$resources[[2]]$data, list('Munich', 'Germany'))\npackage$commit()\nteams \u003c- package$getResource('teams')\nteams$checkRelations()\n# TRUE\n```\n\nFixed! But not only a check operation is available. We could use `relations` argument for `resource$iter/read` methods to dereference a resource relations:\n\n```{r eval=TRUE, include=TRUE}\njsonlite::toJSON(teams$read(keyed = TRUE, relations = FALSE), pretty =  TRUE)\n```\n\nInstead of plain city name we've got a dictionary containing a city data. These `resource$iter/read` methods will fail with the same as `resource$check_relations` error if there is an integrity issue. But only if `relations = TRUE` flag is passed.\n\n## API Referencer\n\n### Package\nPackage representation\n\n* [Package](#Package)\n* _instance_\n* [$valid](#Package+valid) ⇒ \u003ccode\u003eBoolean\u003c/code\u003e\n* [$errors](#Package+errors) ⇒ \u003ccode\u003eList.\u0026lt;Error\u0026gt;\u003c/code\u003e\n* [$profile](#Package+profile) ⇒ \u003ccode\u003eProfile\u003c/code\u003e\n* [$descriptor](#Package+descriptor) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n* [$resources](#Package+resources) ⇒ \u003ccode\u003eList.\u0026lt;Resoruce\u0026gt;\u003c/code\u003e\n* [$resourceNames](#Package+resourceNames) ⇒ \u003ccode\u003eList.\u0026lt;string\u0026gt;\u003c/code\u003e\n* [$getResource(name)](#Package+getResource) ⇒ \u003ccode\u003eResource\u003c/code\u003e \\| \u003ccode\u003enull\u003c/code\u003e\n* [$addResource(descriptor)](#Package+addResource) ⇒ \u003ccode\u003eResource\u003c/code\u003e\n* [$removeResource(name)](#Package+removeResource) ⇒ \u003ccode\u003eResource\u003c/code\u003e \\| \u003ccode\u003enull\u003c/code\u003e\n* [$infer(pattern)](#Package+infer) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n* [$commit(strict)](#Package+commit) ⇒ \u003ccode\u003eBoolean\u003c/code\u003e\n* [$save(target, raises, returns)](#Package+save)\n* _static_\n* [.load(descriptor, basePath, strict)](#Package.load) ⇒ [\u003ccode\u003ePackage\u003c/code\u003e](#Package)\n\n#### package$.valid ⇒ \u003ccode\u003eBoolean\u003c/code\u003e\nValidation status\n\nIt always `true` in strict mode.\n\n**Returns**: \u003ccode\u003eBoolean\u003c/code\u003e - returns validation status  \n\n#### package$errors ⇒ \u003ccode\u003eList.\u0026lt;Error\u0026gt;\u003c/code\u003e\nValidation errors\n\nIt always empty in strict mode.\n\n**Returns**: \u003ccode\u003eList.\u0026lt;Error\u0026gt;\u003c/code\u003e - returns validation errors  \n\n#### package$profile ⇒ \u003ccode\u003eProfile\u003c/code\u003e\nProfile\n\n\n#### package$descriptor ⇒ \u003ccode\u003eObject\u003c/code\u003e\nDescriptor\n\n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - schema descriptor  \n\n#### package$resources ⇒ \u003ccode\u003eList.\u0026lt;Resoruce\u0026gt;\u003c/code\u003e\nResources\n\n\n#### package$resourceNames ⇒ \u003ccode\u003eList.\u0026lt;string\u0026gt;\u003c/code\u003e\nResource names\n\n\n#### package$getResource(name) ⇒ \u003ccode\u003eResource\u003c/code\u003e \\| \u003ccode\u003enull\u003c/code\u003e\nReturn a resource\n\n**Returns**: \u003ccode\u003eResource\u003c/code\u003e \\| \u003ccode\u003enull\u003c/code\u003e - resource instance if exists  \n\n| Param | Type |\n| --- | --- |\n| name | \u003ccode\u003estring\u003c/code\u003e | \n\n\n#### package$addResource(descriptor) ⇒ \u003ccode\u003eResource\u003c/code\u003e\nAdd a resource\n\n**Returns**: \u003ccode\u003eResource\u003c/code\u003e - added resource instance  \n\n| Param | Type |\n| --- | --- |\n| descriptor | \u003ccode\u003eObject\u003c/code\u003e | \n\n\n#### package$removeResource(name) ⇒ \u003ccode\u003eResource\u003c/code\u003e \\| \u003ccode\u003enull\u003c/code\u003e\nRemove a resource\n\n**Returns**: \u003ccode\u003eResource\u003c/code\u003e \\| \u003ccode\u003enull\u003c/code\u003e - removed resource instance if exists  \n\n| Param | Type |\n| --- | --- |\n| name | \u003ccode\u003estring\u003c/code\u003e | \n\n\n#### package$infer(pattern) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nInfer metadata\n\n\n| Param | Type | Default |\n| --- | --- | --- |\n| pattern | \u003ccode\u003estring\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | \n\n\n#### package$commit(strict) ⇒ \u003ccode\u003eBoolean\u003c/code\u003e\nUpdate package instance if there are in-place changes in the descriptor.\n\n**Returns**: \u003ccode\u003eBoolean\u003c/code\u003e - returns true on success and false if not modified  \n**Throws**:\n\n- \u003ccode\u003eDataPackageError\u003c/code\u003e raises any error occurred in the process\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| strict | \u003ccode\u003eboolean\u003c/code\u003e | alter `strict` mode for further work |\n\n**Example**  \n```{r eval=TRUE, include=TRUE}\ndataPackage \u003c- Package.load('{\n\"name\": \"package\",\n\"resources\": [{\"name\": \"resource\", \"data\": [\"data\"]}]\n}')\ndataPackage$descriptor$name # package\ndataPackage$descriptor$name \u003c- 'renamed-package'\ndataPackage$descriptor$name # renamed-package\ndataPackage$commit()\n```\n\n#### package$save(target, raises, returns)\nSave data package to target destination.\n\nIf target path has a  zip file extension the package will be zipped and\nsaved entirely. If it has a json file extension only the descriptor will be saved.\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| target | \u003ccode\u003estring\u003c/code\u003e | path where to save a data package |\n| raises | \u003ccode\u003eDataPackageError\u003c/code\u003e | error if something goes wrong |\n| returns | \u003ccode\u003eboolean\u003c/code\u003e | true on success |\n\n#### Package.load(descriptor, basePath, strict) ⇒ [\u003ccode\u003ePackage\u003c/code\u003e](#Package)\nFactory method to instantiate `Package` class.\n\nThis method is async and it should be used with await keyword or as a `Promise`.\n\n**Returns**: [\u003ccode\u003ePackage\u003c/code\u003e](#Package) - returns data package class instance  \n**Throws**:\n\n- \u003ccode\u003eDataPackageError\u003c/code\u003e raises error if something goes wrong\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| descriptor | \u003ccode\u003estring\u003c/code\u003e \\| \u003ccode\u003eObject\u003c/code\u003e | package descriptor as local path, url or object.   If ththe path has a `zip` file extension it will be unzipped   to the temp directory first. |\n| basePath | \u003ccode\u003estring\u003c/code\u003e | base path for all relative paths |\n| strict | \u003ccode\u003eboolean\u003c/code\u003e | strict flag to alter validation behavior.   Setting it to `true` leads to throwing errors on any operation   with invalid descriptor |\n\n### Resource\nResource representation\n\n\n* [Resource](#Resource)\n* _instance_\n* [$valid](#Resource+valid) ⇒ \u003ccode\u003eBoolean\u003c/code\u003e\n* [$errors](#Resource+errors) ⇒ \u003ccode\u003eList.\u0026lt;Error\u0026gt;\u003c/code\u003e\n* [$profile](#Resource+profile) ⇒ \u003ccode\u003eProfile\u003c/code\u003e\n* [$descriptor](#Resource+descriptor) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n* [$name](#Resource+name) ⇒ \u003ccode\u003estring\u003c/code\u003e\n* [$inline](#Resource+inline) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n* [$local](#Resource+local) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n* [$remote](#Resource+remote) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n* [$multipart](#Resource+multipart) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n* [$tabular](#Resource+tabular) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n* [$source](#Resource+source) ⇒ \u003ccode\u003eList\u003c/code\u003e \\| \u003ccode\u003estring\u003c/code\u003e\n* [$headers](#Resource+headers) ⇒ \u003ccode\u003eList.\u0026lt;string\u0026gt;\u003c/code\u003e\n* [$schema](#Resource+schema) ⇒ \u003ccode\u003etableschema.Schema\u003c/code\u003e\n* [$iter(keyed, extended, cast, forceCast, relations, stream)](#Resource+iter) ⇒ \u003ccode\u003eAsyncIterator\u003c/code\u003e \\| \u003ccode\u003eStream\u003c/code\u003e\n* [$read(limit)](#Resource+read) ⇒ \u003ccode\u003eList.\u0026lt;List\u0026gt;\u003c/code\u003e \\| \u003ccode\u003eList.\u0026lt;Object\u0026gt;\u003c/code\u003e\n* [$checkRelations()](#Resource+checkRelations) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n* [$rawIter(stream)](#Resource+rawIter) ⇒ \u003ccode\u003eIterator\u003c/code\u003e \\| \u003ccode\u003eStream\u003c/code\u003e\n* [$rawRead()](#Resource+rawRead) ⇒ \u003ccode\u003eBuffer\u003c/code\u003e\n* [$infer()](#Resource+infer) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n* [$commit(strict)](#Resource+commit) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n* [$save(target)](#Resource+save) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n* _static_\n* [$load(descriptor, basePath, strict)](#Resource.load) ⇒ [\u003ccode\u003eResource\u003c/code\u003e](#Resource)\n\n\n#### resource$valid ⇒ \u003ccode\u003eBoolean\u003c/code\u003e\nValidation status\n\nIt always `true` in strict mode.\n\n**Returns**: \u003ccode\u003eBoolean\u003c/code\u003e - returns validation status  \n\n#### resource$errors ⇒ \u003ccode\u003eList.\u0026lt;Error\u0026gt;\u003c/code\u003e\nValidation errors\n\nIt always empty in strict mode.\n\n**Returns**: \u003ccode\u003eList.\u0026lt;Error\u0026gt;\u003c/code\u003e - returns validation errors  \n\n#### resource$profile ⇒ \u003ccode\u003eProfile\u003c/code\u003e\nProfile\n\n\n#### resource$descriptor ⇒ \u003ccode\u003eObject\u003c/code\u003e\nDescriptor\n\n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - schema descriptor  \n\n#### resource$name ⇒ \u003ccode\u003estring\u003c/code\u003e\nName\n\n\n#### resource$inline ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nWhether resource is inline\n\n\n#### resource$local ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nWhether resource is local\n\n\n#### resource$remote ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nWhether resource is remote\n\n\n#### resource$multipart ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nWhether resource is multipart\n\n\n#### resource$tabular ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nWhether resource is tabular\n\n\n#### resource$source ⇒ \u003ccode\u003eList\u003c/code\u003e \\| \u003ccode\u003estring\u003c/code\u003e\nSource\n\nCombination of `resource.source` and `resource.inline/local/remote/multipart`\nprovides predictable interface to work with resource data.\n\n\n#### resource$headers ⇒ \u003ccode\u003eList.\u0026lt;string\u0026gt;\u003c/code\u003e\nHeaders\n\n\u003e Only for tabular resources\n\n**Returns**: \u003ccode\u003eList.\u0026lt;string\u0026gt;\u003c/code\u003e - data source headers  \n\n#### resource$schema ⇒ \u003ccode\u003etableschema.Schema\u003c/code\u003e\nSchema\n\n\u003e Only for tabular resources\n\n\n#### resource$iter(keyed, extended, cast, forceCast, relations, stream) ⇒ \u003ccode\u003eAsyncIterator\u003c/code\u003e \\| \u003ccode\u003eStream\u003c/code\u003e\nIterate through the table data\n\n\u003e Only for tabular resources\n\nAnd emits rows cast based on table schema (async for loop).\nWith a `stream` flag instead of async iterator a Node stream will be returned.\nData casting can be disabled.\n\n**Returns**: \u003ccode\u003eAsyncIterator\u003c/code\u003e \\| \u003ccode\u003eStream\u003c/code\u003e - async iterator/stream of rows:\n- `[value1, value2]` - base\n- `{header1: value1, header2: value2}` - keyed\n- `[rowNumber, [header1, header2], [value1, value2]]` - extended  \n**Throws**:\n\n- \u003ccode\u003eTableSchemaError\u003c/code\u003e raises any error occurred in this process\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| keyed | \u003ccode\u003eboolean\u003c/code\u003e | iter keyed rows |\n| extended | \u003ccode\u003eboolean\u003c/code\u003e | iter extended rows |\n| cast | \u003ccode\u003eboolean\u003c/code\u003e | disable data casting if false |\n| forceCast | \u003ccode\u003eboolean\u003c/code\u003e | instead of raising on the first row with cast error   return an error object to replace failed row. It will allow   to iterate over the whole data file even if it's not compliant to the schema.   Example of output stream:     `[['val1', 'val2'], TableSchemaError, ['val3', 'val4'], ...]` |\n| relations | \u003ccode\u003eboolean\u003c/code\u003e | if true foreign key fields will be   checked and resolved to its references |\n| stream | \u003ccode\u003eboolean\u003c/code\u003e | return Node Readable Stream of table rows |\n\n\n#### resource$read(limit) ⇒ \u003ccode\u003eList.\u0026lt;List\u0026gt;\u003c/code\u003e \\| \u003ccode\u003eList.\u0026lt;Object\u0026gt;\u003c/code\u003e\nRead the table data into memory\n\n\u003e Only for tabular resources; the API is the same as `resource.iter` has except for:\n\n**Returns**: \u003ccode\u003eList.\u0026lt;List\u0026gt;\u003c/code\u003e \\| \u003ccode\u003eList.\u0026lt;Object\u0026gt;\u003c/code\u003e - list of rows:\n- `[value1, value2]` - base\n- `{header1: value1, header2: value2}` - keyed\n- `[rowNumber, [header1, header2], [value1, value2]]` - extended  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| limit | \u003ccode\u003einteger\u003c/code\u003e | limit of rows to read |\n\n\n#### resource$checkRelations() ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nIt checks foreign keys and raises an exception if there are integrity issues.\n\n\u003e Only for tabular resources\n\n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - returns True if no issues  \n**Throws**:\n\n- \u003ccode\u003eDataPackageError\u003c/code\u003e raises if there are integrity issues\n\n\n#### resource$rawIter(stream) ⇒ \u003ccode\u003eIterator\u003c/code\u003e \\| \u003ccode\u003eStream\u003c/code\u003e\nIterate over data chunks as bytes. If `stream` is true Node Stream will be returned.\n\n**Returns**: \u003ccode\u003eIterator\u003c/code\u003e \\| \u003ccode\u003eStream\u003c/code\u003e - returns Iterator/Stream  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| stream | \u003ccode\u003eboolean\u003c/code\u003e | Node Stream will be returned |\n\n\n#### resource$rawRead() ⇒ \u003ccode\u003eBuffer\u003c/code\u003e\nReturns resource data as bytes.\n\n**Returns**: \u003ccode\u003eBuffer\u003c/code\u003e - returns Buffer with resource data  \n\n#### resource$infer() ⇒ \u003ccode\u003eObject\u003c/code\u003e\nInfer resource metadata like name, format, mediatype, encoding, schema and profile.\n\nIt commits this changes into resource instance.\n\n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - returns resource descriptor  \n\n#### resource$commit(strict) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nUpdate resource instance if there are in-place changes in the descriptor.\n\n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - returns true on success and false if not modified  \n**Throws**:\n\n- DataPackageError raises error if something goes wrong\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| strict | \u003ccode\u003eboolean\u003c/code\u003e | alter `strict` mode for further work |\n\n\n#### resource$save(target) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nSave resource to target destination.\n\n\u003e For now only descriptor will be saved.\n\n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - returns true on success  \n**Throws**:\n\n- \u003ccode\u003eDataPackageError\u003c/code\u003e raises error if something goes wrong\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| target | \u003ccode\u003estring\u003c/code\u003e | path where to save a resource |\n\n\n#### Resource.load(descriptor, basePath, strict) ⇒ [\u003ccode\u003eResource\u003c/code\u003e](#Resource)\nFactory method to instantiate `Resource` class.\n\nThis method is async and it should be used with await keyword or as a `Promise`.\n\n**Returns**: [\u003ccode\u003eResource\u003c/code\u003e](#Resource) - returns resource class instance  \n**Throws**:\n\n- \u003ccode\u003eDataPackageError\u003c/code\u003e raises error if something goes wrong\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| descriptor | \u003ccode\u003estring\u003c/code\u003e \\| \u003ccode\u003eObject\u003c/code\u003e | resource descriptor as local path, url or object |\n| basePath | \u003ccode\u003estring\u003c/code\u003e | base path for all relative paths |\n| strict | \u003ccode\u003eboolean\u003c/code\u003e | strict flag to alter validation behavior.   Setting it to `true` leads to throwing errors on   any operation with invalid descriptor |\n\n\n### Profile\nProfile representation\n\n\n* [Profile](#Profile)\n* _instance_\n* [$name](#Profile+name) ⇒ \u003ccode\u003estring\u003c/code\u003e\n* [$jsonschema](#Profile+jsonschema) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n* [$validate(descriptor)](#Profile+validate) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n* _static_\n* [$load(profile)](#Profile.load) ⇒ [\u003ccode\u003eProfile\u003c/code\u003e](#Profile)\n\n\n#### profile$name ⇒ \u003ccode\u003estring\u003c/code\u003e\nName\n\n\n#### profile$jsonschema ⇒ \u003ccode\u003eObject\u003c/code\u003e\nJsonSchema\n\n\n#### profile$validate(descriptor) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nValidate a data package `descriptor` against the profile.\n\n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - returns a `{valid, errors}` object  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| descriptor | \u003ccode\u003eObject\u003c/code\u003e | retrieved and dereferenced data package descriptor |\n\n\n#### Profile.load(profile) ⇒ [\u003ccode\u003eProfile\u003c/code\u003e](#Profile)\nFactory method to instantiate `Profile` class.\n\nThis method is async and it should be used with await keyword or as a `Promise`.\n\n**Returns**: [\u003ccode\u003eProfile\u003c/code\u003e](#Profile) - returns profile class instance  \n**Throws**:\n\n- \u003ccode\u003eDataPackageError\u003c/code\u003e raises error if something goes wrong\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| profile | \u003ccode\u003estring\u003c/code\u003e | profile name in registry or URL to JSON Schema |\n\n\n### validate(descriptor) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nThis function is async so it has to be used with `await` keyword or as a `Promise`.\n\n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - returns a `{valid, errors}` object  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| descriptor | \u003ccode\u003estring\u003c/code\u003e \\| \u003ccode\u003eObject\u003c/code\u003e | data package descriptor (local/remote path or object) |\n\n\n### infer(pattern) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nThis function is async so it has to be used with `await` keyword or as a `Promise`.\n\n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - returns data package descriptor  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| pattern | \u003ccode\u003estring\u003c/code\u003e | glob file pattern |\n\n\n### DataPackageError\nBase class for the all DataPackage errors.\n\n\n### TableSchemaError\nBase class for the all TableSchema errors.\n\n# Contributing\nThe project follows the [Open Knowledge International coding standards][coding_standards]. There are common commands to work with the project.Recommended way to get started is to create, activate and load the package environment. To install package and development dependencies into active environment:\n\n```{r, eval=FALSE, include=T}\ndevtools::install_github(\"frictionlessdata/datapackage-r\", dependencies=TRUE)\n```\n\nTo make test:\n```{r, eval=FALSE, include=TRUE}\ntest_that(description, {\nexpect_equal(test, expected result)\n})\n```\n\nTo run tests:\n```{r, eval=FALSE, include=TRUE, warning=FALSE}\ndevtools::test()\n```\nmore detailed information about how to create and run tests you can find in [testthat package](https://github.com/hadley/testthat)\n\n## Changelog - News\n\nIn [NEWS.md][news] described only breaking and the most important changes. The full changelog could be found in nicely formatted [commit][commits] history.  \n\n\n[Rs]: https://www.r-project.org/\n[R]: https://cran.r-project.org//\n[Rman]: https://cran.r-project.org/doc/manuals/R-admin.html\n[Rstudio]: https://www.rstudio.com/\n[Rstudiodown]: https://www.rstudio.com/products/rstudio/download/\n[coding_standards]: https://github.com/okfn/coding-standards\n[datapackage]: https://specs.frictionlessdata.io/data-package/\n[news]: https://github.com/frictionlessdata/datapackage-r/blob/master/NEWS.md\n[commits]: https://github.com/frictionlessdata/datapackage-r/commits/master\n\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrictionlessdata%2Fdatapackage-r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrictionlessdata%2Fdatapackage-r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrictionlessdata%2Fdatapackage-r/lists"}