code: def run_r(
      *exprs,
      file=None,
      infile=None,
      vanilla=True,
      args=None,
      default_packages="base",
      **run_kwargs,
  ):
      """Run R code in a subprocess, return stderr+stdout output in a single string.
  
      This has different defaults from `Rscript`, designed for isolated,
      fast invocations.
  
      Args:
        `exprs`: strings of individual R expressions to be evaluated sequentially
        `file`: path to an R script
        `infile`: multiline string of R code, piped into Rscript frontend via stdin.
  
      """
      _check_run_args(exprs, file, infile)
      cmd = ["Rscript"]
      if default_packages:
          cmd.append(f"--default-packages={default_packages}")
      if vanilla:
          cmd.append("--vanilla")
      if file:
          cmd.append(file)
      elif exprs:
          for e in exprs:
              cmd.extend(["-e", e])
      elif infile:
          cmd.append("-")
          run_kwargs["input"] = infile.encode()
  
      if args:
          cmd.extend(args)
  
      run_kwargs.setdefault("capture_output", True)
  
      try:
          return subprocess.run(
              cmd, check=True, **run_kwargs
          ).stdout.decode()
      except subprocess.CalledProcessError as e:
          raise RScriptProcessError(
              e.stderr.decode(), e.returncode
          ) from None
  
file_path: guildai/guild/plugins/r_util.py
imports: import os
  import re
  import subprocess
  from guild import util
label_desc: Use image node_id 6 for calling a global function with example usage: run_r() and returns: subprocess