A tool for generating ReadMe files in accordance with Standards for Astronomical Catalogues, 2.0.
The package is built around a single R6
class (ReadMeGen
), which is used to construct the appropriate description and format data to ascii
plain-text strings.
library(rastrocat) library(vctrs) library(tibble, warn.conflicts = FALSE) library(dplyr, warn.conflicts = FALSE) library(purrr, warn.conflicts = FALSE) # "Lorem ipsum" is used as a standard long-text filler and as a tool for # line wrapping correction tests. lorem_ipsum <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Now, start we creating generator (providing some of the mandatory fields):
gen <- ReadMeGen$new( "ID-123", # Short id "Test Project", # Short title vec_c("de FName Author_1 A.-K.", "Author_2 B.L.", "Author_3 C.M.", "Author_4 D.N.", "Author_5 E.O.", "Author_6 F.P.", "Author_7 G.Q.", "Author_8 H.R.", "Author_9 I.S.", "Author_10 J.T."), # Authors list 2020L) # Year of puclication
Add optional description, abstract and full title:
gen$Description <- lorem_ipsum gen$Abstract <- lorem_ipsum gen$FullTitle <- "A very long title of the table"
References in plain text & bibcodes:
# Supports tidy dots gen$set_references( c(" Astron. Astrophys. Suppl. Ser., 119, 91-98 (1996)", "Astron. Astrophys. Suppl. Ser., 119, 91-98 (1996)"), "The Messenger 81, 20 (1995)") gen$set_bibcode_references(c("1996A&AS..119...91T", "=1996A&AS..119...91T"), "=1995Msngr..81...20D")
Generate format table using mtcars
dataset as source:
# `Format` and `Label` are required frmt <- tibble( Format = vec_repeat("F5.1", ncol(mtcars)), Label = names(mtcars), Explanations = "?") %>% mutate(Explanations = if_else(row_number() == 10L, lorem_ipsum, Explanations))
Assign format table as well as two datasets with similar structure:
gen$assign_multiple_datasets( frmt, tibble( Data = list(mtcars, slice(mtcars, 1:10)), FileName = c("mtcars.dat", "mtcars_short.dat"), Description = c(lorem_ipsum, "None")))
Adding table notes and final remarks:
gen$TableNotes <- lorem_ipsum # Remarks should be named and a split into paragraphs gen$set_remarks("First" = vec_c(lorem_ipsum, lorem_ipsum), !!!list("Second" = lorem_ipsum))
The ReadMe file is generated by calling public $generate_readme()
as a sequence of standard 80-character strings:
ReadMe
gen$generate_readme() %>% paste(collapse = "\n") %>% cat
And data is transformed to the appropriate format using $generate_data()
:
Data
gen$generate_data() %>% map(paste, collapse = "\n") %>% iwalk(~{cat(.y); cat("\n"); cat(.x); cat("\n")})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.