Learn R Programming

this.path (version 2.5.0)

set.jupyter.path: Declare Executing 'Jupyter' Notebook's Filename

Description

this.path() does some guess work to determine the path of the executing notebook in ‘Jupyter’. This involves listing all the files in the initial working directory, filtering those which are R notebooks, then filtering those with contents matching the top-level expression.

This could possibly select the wrong file if the same top-level expression is found in another file. As such, you can use set.jupyter.path() to declare the executing ‘Jupyter’ notebook's filename.

Usage

set.jupyter.path(...)

Value

character string, invisibly; the declared path for ‘Jupyter’.

Arguments

...

further arguments passed to path.join(). If no arguments are provided or exactly one argument is provided that is NA or NULL, the ‘Jupyter’ path is unset.

Details

This function may only be called from a top-level context in ‘Jupyter’. It is recommended that you do NOT provide an absolute path. Instead, provide just the basename and the directory will be determined by the initial working directory.

Examples

Run this code
# ## if you opened the file "~/file50b816a24ec1.ipynb", the initial
# ## working directory should be "~". You can write:
#
# set.jupyter.path("file50b816a24ec1.ipynb")
#
# ## and then this.path() will return "~/file50b816a24ec1.ipynb"

Run the code above in your browser using DataLab