Closed 1beb closed 4 years ago
If you could show me how to convert a ds to the json / csv formats you have in https://github.com/Crunch-io/rcrunch/tree/master/inst/example-datasets I would submit a PR for this
@1beb check out the new Schema endpoint — it provides a view of base data (not derivations) consistent with what is accepted in a create-dataset payload. Reminds me we should think about how to expose and interact with that endpoint here.
Ok, this looks about right so far:
toJSON(crGET("https://app.crunch.io/api/datasets/<DATASETID>/schema"))
But how do I generate the csv?
write.csv(as.data.frame(
?
There's also exportDataset
The problem I'm having is that the weight
variable doesn't appear to come through in the schema.
reprex:
library(crunch)
ds = newExampledataset()
ds$weight = makeWeight(ds$q1 ~ c(0.75, 0.15, 0.10), name = "weight")
modifyWeightVariables(ds, "weight") # Assign "weight" as the weighting variable
exportDataset(ds, "example-dataset.csv") # has a column called weight as expected
# write.csv(as.data.frame(ds), "examples-dataset.csv") # has weight
toJSON(crGET("https://app.crunch.io/api/datasets/<DATASETID>/schema")) # no weight var
In addition, when trying to use the endpoint provided as the data it fails in createDatasetWithMediaAndData
. I spent some time trying to manipulate the JSON result from the endpoint but it still looked different than the initial pets and it wasn't clear why it was being rejected.
Closing for now. Identified API issue where numeric variables output ids at schema end point making automatic round trips of data creation require a lot of munging.
When writing vignettes or creating examples for using R crunch, it would be useful if the example dataset came with a few more batteries included.
We, internally, already have a candidate dataset that is an extension of the current one.