Format the path to output file

format_table_path(file, dir = NULL, path.type = c("proj", "none", "raw"))

Arguments

file

the name of the output file.

dir

the directory where the output file is stored.

path.type

a character string indicating how the path to the output file should be formatted; use "proj" to have the path expressed relative to an RStudio project file; use "none" to format without any directory information (just the output file name); use "raw" to print the complete path to the file using dir as-is.

Value

A string with the formatted table file path.

Details

Note that the default value for path.type is "proj". This requires that an RStudio project file is able to be found using rprojroot::find_root() with the rprojroot::is_rstudio_project criterion.

Once pmtables finds a root for a given working directory, it caches the value for the remainder of the R session. An error will be generated if a table is attempted to be saved using path.type="proj" but an RStudio project file was not able to be located.

Examples

if (FALSE) { # \dontrun{
format_table_path("foo.tex", "my/path")
format_table_path("foo.tex", "my/path", path.type = "proj")
format_table_path("foo.tx", "my/path", path.type = "raw")
} # }