| Title: | R Interface for 'TiddlyWiki' |
|---|---|
| Description: | 'TiddlyWiki' is a unique non-linear notebook for capturing, organising and sharing complex information. 'rtiddlywiki' is a R interface of 'TiddlyWiki' <https://tiddlywiki.com> to create new tiddler from 'R Markdown' file, and then put into a local 'TiddlyWiki' server if it is available. |
| Authors: | Bangyou Zheng [aut, cre] |
| Maintainer: | Bangyou Zheng <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.5.2 |
| Built: | 2026-05-17 05:28:36 UTC |
| Source: | https://github.com/byzheng/rtiddlywiki |
This function generates a tabbed HTML interface for displaying multiple R objects such as 'ggplot2' plots and data frames. Each tab can include custom arguments for rendering (e.g., image width or table formatting).
create_tabs(...)create_tabs(...)
... |
Named arguments where each name defines a tab label. Each argument can be either:
|
Supported object types:
'ggplot' objects — rendered as base64-encoded images using 'save_base64()'
'data.frame' or 'tibble' — rendered using 'kable_html()'
Additional arguments passed inside the list are used by the relevant rendering function.
A 'htmltools::tag' object representing the full tab interface. Can be printed in R Markdown documents or displayed interactively in RStudio Viewer.
## Not run: library(ggplot2) # Simple plot and table p <- ggplot(cars) + geom_point(aes(speed, dist)) df <- head(cars) # Basic usage create_tabs( plot = p, table = df ) # With custom rendering arguments create_tabs( plot = list(object = p, width = 4), table = list(object = df, digits = 2) ) ## End(Not run)## Not run: library(ggplot2) # Simple plot and table p <- ggplot(cars) + geom_point(aes(speed, dist)) df <- head(cars) # Basic usage create_tabs( plot = p, table = df ) # With custom rendering arguments create_tabs( plot = list(object = p, width = 4), table = list(object = df, digits = 2) ) ## End(Not run)
Delete a tiddler
delete_tiddler(title, bag = TW_OPTIONS("bag"))delete_tiddler(title, bag = TW_OPTIONS("bag"))
title |
title of the tiddler to retrieve |
bag |
string defining which recipe to write to (optional, defaults to "default") |
no return values
## Not run: delete_tiddler("GettingStarted") ## End(Not run)## Not run: delete_tiddler("GettingStarted") ## End(Not run)
Get server status
get_status()get_status()
a list of service status
Get a tiddler
get_tiddler(title, recipe = TW_OPTIONS("recipe"))get_tiddler(title, recipe = TW_OPTIONS("recipe"))
title |
title of the tiddler to retrieve |
recipe |
string defining which recipe to read from (optional, defaults to "default") |
tiddler information in JSON format
## Not run: get_tiddler("GettingStarted") ## End(Not run)## Not run: get_tiddler("GettingStarted") ## End(Not run)
Get all tiddlers
get_tiddlers(filter = NULL, exclude = NULL, recipe = TW_OPTIONS("recipe"))get_tiddlers(filter = NULL, exclude = NULL, recipe = TW_OPTIONS("recipe"))
filter |
filter identifying tiddlers to be returned (optional, defaults to "[all[tiddlers]!is[system]sort[title]]") |
exclude |
comma delimited list of fields to excluded from the returned tiddlers (optional, defaults to "text") |
recipe |
string defining which recipe to read from (optional, defaults to "default") |
all tiddlers information in JSON format
## Not run: #' Get all tiddlers get_tiddlers() ## End(Not run)## Not run: #' Get all tiddlers get_tiddlers() ## End(Not run)
Convert Data Frame to HTML Table using kable
kable_html(df, ...)kable_html(df, ...)
df |
A data frame to be converted to an HTML table. |
... |
Other arguments to be passed to 'knitr::kable'. |
A htmltools object containing the HTML representation of the table.
kable_html(cars[1:10,])kable_html(cars[1:10,])
Print tw_html object
## S3 method for class 'tw_html' print(x, ...)## S3 method for class 'tw_html' print(x, ...)
x |
a 'tw_html' object. |
... |
additional arguments passed to or from other methods. |
no return
Put a tiddler
put_tiddler( title, text, type = c("text/vnd.tiddlywiki", "text/x-tiddlywiki", "text/x-markdown", "text/html", "text/plain", "application/json"), tags = NULL, fields = NULL, recipe = TW_OPTIONS("recipe") )put_tiddler( title, text, type = c("text/vnd.tiddlywiki", "text/x-tiddlywiki", "text/x-markdown", "text/html", "text/plain", "application/json"), tags = NULL, fields = NULL, recipe = TW_OPTIONS("recipe") )
title |
tiddler title |
text |
tiddler text |
type |
tiddler type |
tags |
tiddler tags which is merged with existing tags |
fields |
a named vector for tiddler fields which is merged with existing tags |
recipe |
string defining which recipe to write to (optional, defaults to "default") |
No return value
## Not run: title <- "New tiddler" text <- c("!! Section", "This is a new tiddler") type <- "text/vnd.tiddlywiki" tags <- c("Tag1", "Tag 2") fields <- c("F1" = "V1", "F2" = "V2") put_tiddler(title = title, text = text, type = type, tags = tags, fields = fields) ## End(Not run)## Not run: title <- "New tiddler" text <- c("!! Section", "This is a new tiddler") type <- "text/vnd.tiddlywiki" tags <- c("Tag1", "Tag 2") fields <- c("F1" = "V1", "F2" = "V2") put_tiddler(title = title, text = text, type = type, tags = tags, fields = fields) ## End(Not run)
This function parses a table written in TiddlyWiki format and converts it into an R data frame. It can optionally treat the first row as a header.
read_table(table, header = TRUE)read_table(table, header = TRUE)
table |
A character string representing the TiddlyWiki table. |
header |
A logical value indicating whether the first row should be treated as column headers. Default is TRUE. |
A data frame containing the parsed table data.
table <- "|!Cell1 |!Cell2 |\n|Cell3 |Cell4 |" df <- read_table(table, header = TRUE) print(df)table <- "|!Cell1 |!Cell2 |\n|Cell3 |Cell4 |" df <- read_table(table, header = TRUE) print(df)
Remove fields from tiddlers
remove_fields(title, fields, recipe = TW_OPTIONS("recipe"))remove_fields(title, fields, recipe = TW_OPTIONS("recipe"))
title |
tiddler title |
fields |
fields to remove |
recipe |
string defining which recipe to write to (optional, defaults to "default") |
no return value
Save ggplot into base64
save_base64(plot, width = NULL, height = NULL, dpi = NULL, ...)save_base64(plot, width = NULL, height = NULL, dpi = NULL, ...)
plot |
object for ggplot2 or a function for plot |
width |
image width |
height |
image height |
dpi |
image resolution |
... |
Other arguments for plot function |
character string for base64 image
## Not run: library(ggplot2) p <- cars |> ggplot() + geom_point(aes(speed, dist)) p |> save_base64() ## End(Not run)## Not run: library(ggplot2) p <- cars |> ggplot() + geom_point(aes(speed, dist)) p |> save_base64() ## End(Not run)
Split tiddlywiki field into values
split_field(s)split_field(s)
s |
a string |
an vector of values
This function creates a tabbed interface where each tab has dynamically generated content.
tabs(names, fun, groupname = .unique_name(), checked = 1, ...)tabs(names, fun, groupname = .unique_name(), checked = 1, ...)
names |
A character vector of tab labels. |
fun |
A function that generates the content for each tab. It must take an index ('i') as the first argument. |
groupname |
A unique string to group the radio inputs (default is generated automatically). |
checked |
The index of the tab that should be pre-selected (default is '1'). |
... |
Additional arguments passed to 'fun'. |
An 'htmltools::tagList' containing the tabbed interface.
## Not run: tab_labels <- c("Tab1", "Tab2", "Tab3") tab_content_fun <- function(i, extra_text = "") { htmltools::tagList( htmltools::tags$p(paste("Content for tab:", tab_labels[i], extra_text)), htmltools::tags$img(src = paste0("plot_", i, ".png"), width = "100%") ) } tabs(tab_labels, tab_content_fun, checked = 2, extra_text = "Additional details") ## End(Not run)## Not run: tab_labels <- c("Tab1", "Tab2", "Tab3") tab_content_fun <- function(i, extra_text = "") { htmltools::tagList( htmltools::tags$p(paste("Content for tab:", tab_labels[i], extra_text)), htmltools::tags$img(src = paste0("plot_", i, ".png"), width = "100%") ) } tabs(tab_labels, tab_content_fun, checked = 2, extra_text = "Additional details") ## End(Not run)
Format for converting from R Markdown to another tiddler markdown
tiddler_document( host = NULL, remote = FALSE, preview = FALSE, tags = NULL, fields = NULL, use_bookdown = FALSE, overwrite = FALSE, variant = "gfm", pandoc_args = "--wrap=none", ... )tiddler_document( host = NULL, remote = FALSE, preview = FALSE, tags = NULL, fields = NULL, use_bookdown = FALSE, overwrite = FALSE, variant = "gfm", pandoc_args = "--wrap=none", ... )
host |
the host of tiddlywiki web server |
remote |
whether put into remote TiddlyWiki Node.js Server |
preview |
whether to send 'open_tiddler' command to ws server (tw-livebridge) to preview in browser |
tags |
tiddler tags |
fields |
a named vector for tiddler fields |
use_bookdown |
logical. Use bookdown to generate markdown file. |
overwrite |
whether to overwrite the existing tiddler. |
variant |
variant for md_document |
pandoc_args |
pandoc_args for md_document |
... |
Other argument pass to md_document |
R Markdown output format to pass to render()
## Not run: library(rmarkdown) render("input.Rmd") ## End(Not run)## Not run: library(rmarkdown) render("input.Rmd") ## End(Not run)
Generate tiddler in json format
tiddler_json( title, text, type = c("text/vnd.tiddlywiki", "text/x-tiddlywiki", "text/x-markdown", "text/html", "text/plain", "application/json"), tags = NULL, fields = NULL, format = c("json", "list") )tiddler_json( title, text, type = c("text/vnd.tiddlywiki", "text/x-tiddlywiki", "text/x-markdown", "text/html", "text/plain", "application/json"), tags = NULL, fields = NULL, format = c("json", "list") )
title |
tiddler title |
text |
tiddler text |
type |
tiddler type |
tags |
a vector for tiddler tags |
fields |
a named vector for tiddler fields. |
format |
export format as json or list |
New tiddler in json format
Generate tiddler in json format
tiddler_json2(tiddler)tiddler_json2(tiddler)
tiddler |
A list for new tiddler |
New tiddler in json format
Set or get options for my package
tw_options(...)tw_options(...)
... |
Option names to retrieve option values or |
the default and modified options.
The following options are supported host: Host of tiddlywiki recipe: Recipes are named lists of bags, ordered from lowest priority to highest bag: Bags have access controls that determines which users can read or write to them
tw_options(host = "http://127.0.0.1:8080/")tw_options(host = "http://127.0.0.1:8080/")
Reset global options for pkg
tw_reset()tw_reset()
the default options
tw_options()tw_options()
Convert data.frame into table of TiddlyWiki
tw_table(df, collapse = "\n")tw_table(df, collapse = "\n")
df |
data.frame object |
collapse |
an optional character string to separate the results. |
character string for table in TiddlyWiki
cars |> dplyr::slice(1:10) |> tw_table()cars |> dplyr::slice(1:10) |> tw_table()
Create a tiddlywiki widget from htmlwidget
tw_widget(widget, is_cat = FALSE)tw_widget(widget, is_cat = FALSE)
widget |
an object of htmlwidget |
is_cat |
whether to show results on screen |
a new tiddlywiki widget
library(leaflet) ## Not run: content <- paste(sep = "<br/>", "<b><a href='http://www.samurainoodle.com'>Samurai Noodle</a></b>", "606 5th Ave. S", "Seattle, WA 98138" ) widget <- leaflet() %>% addTiles() %>% addPopups(-122.327298, 47.597131, content, options = popupOptions(closeButton = FALSE) ) tw_widget(widget) ## End(Not run)library(leaflet) ## Not run: content <- paste(sep = "<br/>", "<b><a href='http://www.samurainoodle.com'>Samurai Noodle</a></b>", "606 5th Ave. S", "Seattle, WA 98138" ) widget <- leaflet() %>% addTiles() %>% addPopups(-122.327298, 47.597131, content, options = popupOptions(closeButton = FALSE) ) tw_widget(widget) ## End(Not run)
backticks for wikitext
wikitext_backticks_return(x)wikitext_backticks_return(x)
x |
character vector |
By default this function outputs (see: cat) the result. Call the function ending in .return to catch the result instead.
wikitext_backticks('FOO') wikitext_backticks_return('FOO')wikitext_backticks('FOO') wikitext_backticks_return('FOO')
This function converts a Word ('.docx') file to Markdown using Pandoc. Optionally, it embeds images as Base64 for a self-contained Markdown file.
word_to_md( docx_file, output_file = NULL, embed_images = FALSE, overwrite = FALSE )word_to_md( docx_file, output_file = NULL, embed_images = FALSE, overwrite = FALSE )
docx_file |
Path to the input Word file. |
output_file |
Path to the final Markdown output file. If null, the original file name. |
embed_images |
Logical. If 'TRUE', all images will be embedded as Base64. Default is 'FALSE'. |
overwrite |
Logical. If 'TRUE', Output file is overwrote. Default is 'FALSE' |
Saves a Markdown file (optionally with Base64-embedded images).
# Convert Word to Markdown without embedding images ## Not run: word_to_md("input.docx", "output.md", embed_images = FALSE) # Convert and embed images as Base64 word_to_md("input.docx", "output_embedded.md", embed_images = TRUE) ## End(Not run)# Convert Word to Markdown without embedding images ## Not run: word_to_md("input.docx", "output.md", embed_images = FALSE) # Convert and embed images as Base64 word_to_md("input.docx", "output_embedded.md", embed_images = TRUE) ## End(Not run)