55 :target: https://anaconda.org/pytask/pytask-r
66
77.. image :: https://github.com/pytask-dev/pytask-r/workflows/Continuous%20Integration%20Workflow/badge.svg?branch=main
8- :target: https://github.com/pytask-dev/pytask/actions?query=branch%3Amain
8+ :target: https://github.com/pytask-dev/pytask-r /actions?query=branch%3Amain
99
1010.. image :: https://codecov.io/gh/pytask-dev/pytask-r/branch/main/graph/badge.svg
1111 :target: https://codecov.io/gh/pytask-dev/pytask-r
1818pytask-r
1919========
2020
21- pytask-r allows you to run R scripts with pytask.
21+ Run R scripts with pytask.
2222
2323
2424Installation
@@ -31,17 +31,17 @@ Install the plugin with
3131 $ conda config --add channels conda-forge --add channels pytask
3232 $ conda install pytask-r
3333
34- You also need to have R installed and ``Rscript `` on your command line. To test
35- whether it is installed, type the following on the command line
34+ You also need to have R installed and ``Rscript `` on your command line. Test it by
35+ typing the following on the command line
3636
3737.. code-block :: console
3838
3939 $ Rscript --help
4040
4141 If an error is shown instead of a help page, you can install R with ``conda `` by
42- choosing either the normal R or Microsoft R Open (MRO). The command is one of the two
43- following commands. (See `here <https://docs.anaconda.com/anaconda/user-guide/tasks/
44- using-r-language> `_ for further explanation on Anaconda, R, and MRO.)
42+ choosing either R or Microsoft R Open (MRO). Choose one of the two following commands.
43+ (See `here <https://docs.anaconda.com/anaconda/user-guide/tasks/ using-r-language >`_
44+ for further explanation on Anaconda, R, and MRO.)
4545
4646.. code-block :: console
4747
@@ -54,9 +54,9 @@ Or install install R from the official `R Project <https://www.r-project.org/>`_
5454Usage
5555-----
5656
57- Similarly to normal task functions which execute Python code, you also define tasks to
57+ Similarly to normal task functions which execute Python code, you define tasks to
5858execute scripts written in R with Python functions. The difference is that the function
59- body does not contain any logic, but the decorators tell pytask how to handle the task.
59+ body does not contain any logic, but the decorator tells pytask how to handle the task.
6060
6161Here is an example where you want to run ``script.r ``.
6262
@@ -72,27 +72,27 @@ Here is an example where you want to run ``script.r``.
7272 pass
7373
7474 Note that, you need to apply the ``@pytask.mark.r `` marker so that pytask-r handles the
75- task. The first dependency is always treated as the executable script. With multiple
76- dependencies it may look like this
75+ task. The executable script must be the first dependency. Other dependencies can be
76+ added after that.
7777
7878.. code-block :: python
7979
8080 @pytask.mark.r
81- @pytask.mark.depends_on (" script.r" , " input.rds" )
81+ @pytask.mark.depends_on ([ " script.r" , " input.rds" ] )
8282 @pytask.mark.produces (" out.rds" )
8383 def task_run_r_script ():
8484 pass
8585
8686 If you are wondering why the function body is empty, know that pytask-r replaces the
87- body with an predefined internal function. See the section on implementation details for
87+ body with a predefined internal function. See the section on implementation details for
8888more information.
8989
9090
9191Command Line Arguments
9292~~~~~~~~~~~~~~~~~~~~~~
9393
94- The decorator can be used to pass command line arguments to ``Rscript `` which is by
95- default the only the ``--vanilla `` flag. If you want to pass arguments to the script via
94+ The decorator can be used to pass command line arguments to ``Rscript `` which is, by
95+ default, only the ``--vanilla `` flag. If you want to pass arguments to the script via
9696the command line, use
9797
9898.. code-block :: python
@@ -115,7 +115,7 @@ Parametrization
115115~~~~~~~~~~~~~~~
116116
117117You can also parametrize the execution of scripts, meaning executing multiple R scripts
118- as well as passing different command line arguments to an R script.
118+ as well as passing different command line arguments to the same R script.
119119
120120The following task executes two R scripts which produce different outputs.
121121
@@ -130,29 +130,30 @@ The following task executes two R scripts which produce different outputs.
130130
131131
132132 If you want to pass different command line arguments to the same R script, you have to
133- include the R decorator in the parametrization just like with
133+ include the `` @pytask.mark.r `` decorator in the parametrization just like with
134134``@pytask.mark.depends_on `` and ``@pytask.mark.produces ``.
135135
136136.. code-block :: python
137137
138138 @pytask.mark.depends_on (" script.r" )
139- @pytask.mark.parametrize (" produces, r" , [(" out_1.rds" , 1 ), (" out_2.rds" , 2 )])
139+ @pytask.mark.parametrize (
140+ " produces, r" ,
141+ [(" output_1.rds" , [" --vanilla" , 1 ]), (" output_2.rds" , [" --vanilla" , 2 ])],
142+ )
140143 def task_execute_r_script ():
141144 pass
142145
143146
144- .. _implementation_details :
145-
146147 Implementation Details
147148----------------------
148149
149- The plugin is only a convenient wrapper around
150+ The plugin is a convenient wrapper around
150151
151152.. code-block :: python
152153
153154 import subprocess
154155
155- subprocess.run([" Rscript" , " --vanilla" , " script.r" ])
156+ subprocess.run([" Rscript" , " --vanilla" , " script.r" ], check = True )
156157
157158 to which you can always resort to when the plugin does not deliver functionality you
158159need.
0 commit comments