Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simpleError: col_names must be TRUE, FALSE or a character vector #1

Closed
geotheory opened this issue Jul 2, 2021 · 3 comments
Closed

Comments

@geotheory
Copy link

Following the basic usage instructions gets me:

require(csvwr)
#> Loading required package: csvwr

d <- iris[sample(150,10),]
s <- derive_table_schema(d)
m <- create_metadata(tables=s)
j <- jsonlite::toJSON(m)
cat(j, file="metadata.json")
write.csv(d, 'data.csv')

read_csvw_dataframe("data.csv", "metadata.json")
#> $error
#> <simpleError: `col_names` must be TRUE, FALSE or a character vector>
#> 
#> $filename
#> [1] "data.csv"
#> 
#> $dialect
#> list()
#> 
#> $group_schema
#> list()

@Robsteranium
Copy link
Owner

Thanks for the report @geotheory.

It looks like the readme and vignette are wrong. It works if you instead call create_metadata like:

m <- create_metadata(tables=list(list(tableSchema=s)))

i.e. the tables are a list of tables, each table itself being a list having a tableSchema.

I'll update the documentation and add a test case for round-tripping like this. I think the metadata can look a little different in the single-table case (the table group being optional) so I'd like to double-check with the standard first.

@geotheory
Copy link
Author

That works :) Any plans to support factor class?

@Robsteranium
Copy link
Owner

I've fixed the docs and added a test case, thanks.

Indeed the metadata is different in the single table case, I've created #2 to explore this.

Factors are a good idea. I've created #3 for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants