View source: R/fileNameFactory.R
fileNameFactory | R Documentation |
A function factory to create a function that is used to create a file name with a certain extention.
fileNameFactory(path = "Rdata", extension = ".Rdata", createFolder = TRUE)
path |
the path that is concatenated to a file name. |
extension |
the file extension that is concatenated to a file name. |
createFolder |
logical, whether to create the folder if the path doesn't exist. |
fileNameFactory returns a function that create a file name. That function has two attributs, i.e., 'path' and 'extension'
## Not run:
Rdata = fileNameFactory(path = "Rdata/", ".Rdata")
Rdata
Rdata("asdf")
x = 10
pngs = fileNameFactory("figs/", ".png")
pngs
pngs("pngFig", x)
pdfs = fileNameFactory("pdfs/", ".png")
pdfs
pdfs("first/", "pngFile_", x)
# Once the function is created, the path/extension will not be changed by changing the attributes
attr(pngs, "path") = "figs_2"
pngs
pngs("asdf")
# You need to recreate the function with the new path
pngs2 = fileNameFactory("figs_2/", ".png")
pngs2("asdf")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.