Functions to obtain (
file_ext()), remove (
with_ext()) extensions in filenames.
file_ext(x, extra = "") sans_ext(x, extra = "") with_ext(x, ext, extra = "")
A character of file paths.
Extra characters to be allowed in the extensions. By default,
only alphanumeric characters are allowed (and also some special cases in
‘Details’). If other characters should be allowed, they can be
specified in a character string, e.g.,
A vector of new extensions. It must be either of length 1, or the
same length as
file_ext() is similar to
sans_ext() is similar to
The main differences are that they treat
nb.html as extensions (but functions in the tools package
doesn't allow double extensions by default), and allow characters
# to be present at the end of a filename.
A character vector of the same length as
library(xfun) p = c("abc.doc", "def123.tex", "path/to/foo.Rmd", "backup.ppt~", "pkg.tar.xz") file_ext(p) sans_ext(p) with_ext(p, ".txt") with_ext(p, c(".ppt", ".sty", ".Rnw", "doc", "zip")) with_ext(p, "html") # allow for more characters in extensions p = c("a.c++", "b.c--", "c.e##") file_ext(p) # -/+/# not recognized by default file_ext(p, extra = "-+#")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.