Read and write data frames to/from 'data-package' format. For reading supported paths are disk, http or git. For writing only disk is supported.

datapkg_read(path = getwd())

datapkg_validate(path = getwd())

datapkg_write(data, name, path = getwd())

Arguments

path

file path or URL to the data package directory

data

a data frame to be added to the package

name

what to name this dataset

References

http://frictionlessdata.io/data-packages, https://github.com/datasets

Examples

# Create new data package pkgdir <- tempfile() datapkg_write(mtcars, path = pkgdir)
#> Creating new /tmp/RtmpSC2yD5/file7124ef6b3eb/datapackage.json
datapkg_write(iris, path = pkgdir)
#> Opening existing /tmp/RtmpSC2yD5/file7124ef6b3eb/datapackage.json
# Read it back mypkg <- datapkg_read(pkgdir)
#> Reading file /tmp/RtmpSC2yD5/file7124ef6b3eb/data/mtcars.csv
#> Reading file /tmp/RtmpSC2yD5/file7124ef6b3eb/data/iris.csv
print(mypkg$data$mtcars)
#> # A tibble: 32 x 11 #> mpg cyl disp hp drat wt qsec vs am gear carb #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4 #> 2 21 6 160 110 3.9 2.87 17.0 0 1 4 4 #> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1 #> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1 #> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2 #> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1 #> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4 #> 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2 #> 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2 #> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4 #> # … with 22 more rows
# Clone package with git: cities <- datapkg_read("git://github.com/datasets/world-cities")
#> cloning into '/tmp/RtmpSC2yD5/file7122323b248'... #> Receiving objects: 1% (2/140), 8 kb #> Receiving objects: 11% (16/140), 8 kb #> Receiving objects: 21% (30/140), 8 kb #> Receiving objects: 31% (44/140), 33 kb #> Receiving objects: 41% (58/140), 33 kb #> Receiving objects: 51% (72/140), 304 kb #> Receiving objects: 61% (86/140), 304 kb #> Receiving objects: 71% (100/140), 304 kb #> Receiving objects: 81% (114/140), 304 kb #> Receiving objects: 91% (128/140), 304 kb #> Receiving objects: 100% (140/140), 304 kb, done.
#> Reading file /tmp/RtmpSC2yD5/file7122323b248/data/world-cities.csv
# Read over http euribor <- datapkg_read("https://raw.githubusercontent.com/datasets/euribor/master")
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-10m-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-11m-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-12m-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-1m-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-1w-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-2m-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-2w-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-3m-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-3w-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-4m-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-5m-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-6m-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-7m-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-8m-monthly.csv
#> Reading file https://raw.githubusercontent.com/datasets/euribor/master/data/euribor-9m-monthly.csv