Learn R Programming

xfun (version 0.56)

Supporting Functions for Packages Maintained by 'Yihui Xie'

Description

Miscellaneous functions commonly used in other packages maintained by 'Yihui Xie'.

Copy Link

Version

Install

install.packages('xfun')

Monthly Downloads

1,244,977

Version

0.56

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Yihui Xie

Last Published

January 18th, 2026

Functions in xfun (0.56)

env_option

Retrieve a global option from both options() and environment variables
fenced_block

Create a fenced block in Markdown
file_rename

Rename files and directories
do_once

Perform a task once in an R session
embed_file

Embed a file, multiple files, or directory on an HTML page
download_cache

Download a file from a URL and cache it on disk
existing_files

Find file paths that exist
exit_call

Call on.exit() in a parent function
download_file

Try various methods to download a file
file_ext

Manipulate filename extensions
github_releases

Get the tags of GitHub releases of a repository
grep_sub

Perform replacement with gsub() on elements matched from grep()
gsub_file

Search and replace strings in files
html_tag

Tools for HTML tags
install_dir

Install a source package from a directory
in_dir

Evaluate an expression under a specified working directory
from_root

Get the relative path of a path in a project relative to the current working directory
format_bytes

Format numbers of bytes using a specified unit
file_string

Read a text file and concatenate the lines by '\n'
find_globals

Find global/local variables in R code
join_words

Join multiple words into a single string
is_R_CMD_check

Some utility functions for checking packages
is_abs_path

Test if paths are relative or absolute
is_ascii

Check if a character vector consists of entirely ASCII characters
is_web_path

Test if a path is a web path
is_sub_path

Test if a path is a subpath of a dir
is_blank

Test if a character vector consists of blank strings
lazy_save

Save objects to files and lazy-load them
install_github

An alias of remotes::install_github()
magic_path

Find a file or directory under a root directory
md_table

Generate a simple Markdown pipe table
mime_type

Get the MIME types of files
mark_dirs

Mark some paths as directories
native_encode

Try to use the system native encoding to represent a character vector
numbers_to_words

Convert numbers to English words
msg_cat

Generate a message with cat()
md5

Calculate the MD5 checksums of R objects
news2md

Convert package news to the Markdown format
parse_only

Parse R code and do not keep the source
is_windows

Test for types of operating systems
pkg_attach

Attach or load packages, and automatically install missing packages if requested
proc_kill

Kill a process and (optionally) all its child processes
new_app

Create a local web application
normalize_path

Normalize paths
prose_index

Find the indices of lines in Markdown that are prose (not code blocks)
pkg_bib

Generate BibTeX bibliography databases for R packages
process_file

Read a text file, process the text with a function, and write the text back
proj_root

Return the (possible) root directory of a project
protect_math

Protect math expressions in pairs of backticks in Markdown
optipng

Run OptiPNG on all PNG files under a directory
read_utf8

Read / write files encoded in UTF-8
relative_path

Get the relative path of a path relative to a directory
raw_string

Print a character vector in its raw form
read_bin

Read all records of a binary file as a raw vector by default
record_print

Print methods for record()
read_all

Read all text files and concatenate their content
rand_unit

Pseudo-random numbers on [0, 1) based on a linear congruential generator
rest_api

Get data from a REST API
rename_seq

Rename files with a sequential numeric prefix
record

Run R code and record the results
str_wrap

Wrap character vectors
shrink_images

Shrink images to a maximum width
retry

Retry calling a function for a number of times
rev_check

Run R CMD check on the reverse dependencies of a package
session_info

An alternative to sessionInfo() to print session information
set_envvar

Set environment variables
split_lines

Split a character vector by line breaks
rstudio_type

Type a character vector into the RStudio source editor
same_path

Test if two paths are the same after they are normalized
split_source

Split source lines into complete expressions
submit_cran

Submit a source package to CRAN
strip_html

Strip HTML tags
tabset

Represent a (recursive) list with (nested) tabsets
tojson

A simple JSON serializer
system3

Run system2() and mark its character output as UTF-8 if appropriate
try_error

Try an expression and see if it throws an error
tinify

Use the Tinify API to compress PNG and JPEG images
tree

Turn the output of str() into a tree diagram
strict_list

Strict lists
taml_load

A simple YAML reader and writer
url_accessible

Test if a URL is accessible
upload_ftp

Upload to an FTP server via curl
try_silent

Try to evaluate an expression silently
yaml_body

Partition the YAML metadata and the body in a document
url_destination

Get the final destination of a URL
yaml_load

Read YAML data
upload_imgur

Upload an image to imgur.com
url_filename

Extract filenames from a URLs
valid_syntax

Check if the syntax of the code is valid