Skip to contents

This function formats a data frame of articles into a markdown-styled table using the tinytable package. It allows you to select specific columns from the article data and adjust the column widths for a clean, formatted output.

Usage

tt_article(article, cols = c("title", "summary"), width = c(1, 3))

Arguments

article

A data frame containing article information (e.g., "title", "summary", "url").

cols

A character vector of column names to include in the table. Default is c("title", "summary").

width

A numeric vector specifying column widths. Default is c(1, 3).

Value

A formatted markdown table as a character string, ready to be displayed in markdown-supported environments.

Details

The function first ensures that the specified columns exist in the data frame and that the length of cols matches the length of width. It then formats the "title" column as a markdown link, using the article's URL (if provided), and selects the requested columns to be displayed in the table. The resulting table is formatted as markdown for easy integration into markdown environments.

Examples

if (FALSE) { # \dontrun{
papers <- get_articles(journal = "Nature Biotechnology")
papers_with_summary <- add_summary(papers)
tt_article(papers_with_summary)
} # }