Use R code or Windows user variable (%userprofile%) in YAML?
The problem is that the parameters in the output
field is only understood by rmarkdown. Pandoc does not understand them, so you need to make sure rmarkdown can evaluate the expression. Since rmarkdown uses the yaml package to read the YAML metadata, and yaml's syntax for R expressions is !expr
, you can put the R expression after !expr
, e.g.
output:
word_document:
fig_caption: yes
fig_height: 4
fig_width: 7
reference_docx: !expr file.path(Sys.getenv('USERPROFILE'), 'Documents', 'template.docx')
How do I use the user home directory in a Github actions workflow that runs on Windows?
The answer is $HOME
:
steps:
- name: Echo home
run:
echo $HOME
Log:
Run echo $HOME
C:\Users\runneradmin
How to set environment variables in Jenkins?
This can be done via EnvInject plugin in the following way:
Create an "Execute shell" build step that runs:
echo AOEU=$(echo aoeu) > propsfile
Create an Inject environment variables build step and set "Properties File Path" to
propsfile
.
Note: This plugin is (mostly) not compatible with the Pipeline plugin.
Related Topics
Using Parallel's Parlapply: Unable to Access Variables Within Parallel Code
How to Disable "Save Workspace Image" Prompt in R
Grid of Multiple Ggplot2 Plots Which Have Been Made in a for Loop
Can Sweave Produce Many PDFs Automatically
Ggplot2: Adjust the Symbol Size in Legends
Replace All Values in a Matrix <0.1 with 0
Removing Multiple Columns from R Data.Table with Parameter for Columns to Remove
How to Set Fixed Continuous Colour Values in Ggplot2
How to Determine If You Have an Internet Connection in R
Creating Regular 15-Minute Time-Series from Irregular Time-Series
Add a Horizontal Line to Plot and Legend in Ggplot2
Ggplot2 Multiple Scales/Legends Per Aesthetic, Revisited
How to Draw a Nice Arrow in Ggplot2
How to Pass Dynamic Column Names in Dplyr into Custom Function
Import Data into R with an Unknown Number of Columns
Automatically Adjust Latex Table Width to Fit PDF Using Knitr and Rstudio
Moving Color Key in R Heatmap.2 (Function of Gplots Package)