Closed paleolimbot closed 5 years ago
tdir <- tempfile() dir.create(tdir) tf <- file.path(tdir, "temp.Rmd") writeLines( c( "---", "output: md_document", "---", "", "```{r}", "library(mudata2)", "getwd()", "write_mudata_zip(kentvillegreenwood, 'kg.zip')", "write_mudata_json(kentvillegreenwood, 'kg.json')", "```", "" ), tf ) rmarkdown::render(tf) #> processing file: temp.Rmd #> output file: temp.knit.md #> /Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS temp.utf8.md --to markdown_strict --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output temp.md --standalone #> #> Output created: temp.md cat(paste(readLines(file.path(tdir, "temp.md")), collapse = "\n")) #> library(mudata2) #> getwd() #> #> [1] "/private/var/folders/bq/2rcjstv90nx1_wrt8d3gqw6m0000gn/T/Rtmp8WLzt6/filecdbd4b8c12f7" #> write_mudata_zip(kentvillegreenwood, 'kg.zip') #> write_mudata_json(kentvillegreenwood, 'kg.json') mudata2::read_mudata_zip(file.path(tdir, "kg.zip")) #> Error in mudata2::read_mudata_zip(file.path(tdir, "kg.zip")): File /var/folders/bq/2rcjstv90nx1_wrt8d3gqw6m0000gn/T//Rtmp8WLzt6/filecdbd4b8c12f7/kg.zip does not exist mudata2::read_mudata_json(file.path(tdir, "kg.json")) #> A mudata object aligned along "date" #> distinct_datasets(): "ecclimate" #> distinct_locations(): "GREENWOOD A", "KENTVILLE CDA CS" #> distinct_params(): "cooldegdays", "dirofmaxgust" ... and 9 more #> src_tbls(): "data", "locations" ... and 3 more #> #> tbl_data() %>% head(): #> # A tibble: 6 x 6 #> dataset location param date value flags #> <chr> <chr> <chr> <date> <dbl> <chr> #> 1 ecclimate KENTVILLE CDA CS maxtemp 1999-07-01 28.5 <NA> #> 2 ecclimate KENTVILLE CDA CS maxtemp 1999-07-02 30.7 <NA> #> 3 ecclimate KENTVILLE CDA CS maxtemp 1999-07-03 26.4 <NA> #> 4 ecclimate KENTVILLE CDA CS maxtemp 1999-07-04 28.6 <NA> #> 5 ecclimate KENTVILLE CDA CS maxtemp 1999-07-05 26.0 <NA> #> 6 ecclimate KENTVILLE CDA CS maxtemp 1999-07-06 25.3 <NA>