File: thisfile.Rd

package info (click to toggle)
r-cran-rprojroot 2.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 496 kB
  • sloc: sh: 12; makefile: 7
file content (63 lines) | stat: -rw-r--r-- 1,781 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/thisfile.R
\name{thisfile}
\alias{thisfile}
\alias{thisfile_source}
\alias{thisfile_r}
\alias{thisfile_rscript}
\alias{thisfile_knit}
\title{Determines the path of the currently running script}
\usage{
thisfile()

thisfile_source()

thisfile_r()

thisfile_rscript()

thisfile_knit()
}
\value{
The path of the currently running script, NULL if it cannot be
determined.
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#soft-deprecated}{\figure{lifecycle-soft-deprecated.svg}{options: alt='[Soft-deprecated]'}}}{\strong{[Soft-deprecated]}}

\R does not store nor export the path of the currently running
script.  This is an attempt to circumvent this limitation by applying
heuristics (such as call stack and argument inspection) that work in many
cases.
\strong{CAVEAT}: Use this function only if your workflow does not permit other
solution: if a script needs to know its location, it should be set outside
the context of the script if possible.
}
\details{
This functions currently work only if the script was \code{source}d,
processed with \code{knitr},
or run with \code{Rscript} or using the \code{--file} parameter to the
\code{R} executable.  For code run with \code{Rscript}, the exact value
of the parameter passed to \code{Rscript} is returned.
}
\section{Life cycle}{


These functions are now available in the \pkg{whereami} package.
}

\examples{
\dontrun{
thisfile()
}
}
\references{
\url{https://stackoverflow.com/q/1815606/946850}
}
\seealso{
\code{\link[base:source]{base::source()}}, \code{\link[utils:Rscript]{utils::Rscript()}}, \code{\link[base:getwd]{base::getwd()}}
}
\author{
Kirill Müller, Hadley Wickham, Michael R. Head
}
\keyword{internal}