Closed HeidiSeibold closed 5 years ago
The error you get is this: "Error: No method asJSON S3 class: OMLDataSetDescription" ?
I don't get an error, I just don't know where to start.
I got this far
library("datapackage.r")
dataPackage <- Package.load(descriptor = list(profile = "tabular-data-package",
title = omldat$desc$name,
name = omldat$desc$name))
Now where do I enter the data.frame, how do I add the info on the variable types (or does it do that automatically for data.frames?), ...
I can't use the basePath argument since I have the data set already loaded as a data.frame. All your examples show how to work with csv-files. None show how to work with data already loaded into R.
Inputs in datapackage should be lists or json. One option is to make a list of both resources and to convert them to json.
resources=append(omldat$desc,list(data = omldat$data))
descriptor = list(resources=list(resources))
library(datapackage.r)
descriptor = helpers.from.list.to.json(descriptor)
Then you could instantiate your Package
class:
datapackage = Package.load(descriptor)
and for example you can retrieve back your data as list:
datapackage$resources[[1]]$read()
or as data frame:
jsonlite::fromJSON(helpers.from.list.to.json(datapackage$resources[[1]]$read()))
I have the following data set:
I have additional meta information:
The meta information includes things that can also be represented in data packages, such as
description
andlicence
as well as something likecitation
, which I assume should be thesources
field in the data package.I have been trying for a little while now to create a
Package
object from this with all the meta data. Using the vignette I was not able to do this. Can you help me out there? I would very much appreciate this :cake:Background info: we would like to allow exporting OpenML datasets to data packages (https://github.com/openml/OpenML/issues/482).