Learn R Programming

wrMisc (version 1.15.3.1)

correctWinPath: Correct mixed slash and backslash in file path

Description

This function corrects paths character strings for mixed slash and backslash in file path. In Windows the function tempdir() will use double backslashes as separator while file.path() uses regular slashes. So when combining these two one might encounter a mix of slashes and double backslashes which may cause trouble, unless this is streightened out to a single separator used. When pointig to given files inside html-files, paths need to have a prefix, this can be added using the argument asHtml.

Usage

correctWinPath(
  x,
  asHtml = FALSE,
  anyPlatf = FALSE,
  silent = TRUE,
  callFrom = NULL
)

Value

character vector with corrected path

Arguments

x

(character) input path to test and correct

asHtml

(logical) option for use in html : add prefix "file:/"

anyPlatf

(logical) if TRUE, checking will only be performed in Windows environement

silent

(logical) suppress messages

callFrom

(character) allows easier tracking of message(s) produced

See Also

Examples

Run this code
path1 <- 'D:\\temp\\Rtmp6X8/working_dir\\RtmpKC/example.txt'
(path1b <- correctWinPath(path1, anyPlatf=TRUE)) 
(path1h <- correctWinPath(path1, anyPlatf=TRUE, asHtml=TRUE)) 

Run the code above in your browser using DataLab