class_docstr: A printer to convert SymPy expressions to strings of R code
class_docstr_tok: ["A","printer","to","convert","SymPy","expressions","to","strings","of","R","code"]
code: def _print_Piecewise(self, expr):
      # This method is called only for inline if constructs
      # Top level piecewise is handled in doprint()
      if expr.args[-1].cond == True:
          last_line = "%s" % self._print(expr.args[-1].expr)
      else:
          last_line = "ifelse(%s,%s,NA)" % (
              self._print(expr.args[-1].cond),
              self._print(expr.args[-1].expr),
          )
      code = last_line
      for e, c in reversed(expr.args[:-1]):
          code = (
              "ifelse(%s,%s," % (self._print(c), self._print(e))
              + code
              + ")"
          )
      return code
  
imports: from __future__ import annotations
  from typing import Any
  from sympy.core.numbers import equal_valued
  from sympy.printing.codeprinter import CodePrinter
  from sympy.printing.precedence import precedence, PRECEDENCE
  from sympy.sets.fancysets import Range
label_desc: Use image node_id 18 for calling the RCodePrinter obj's underlying member method code with example usage: obj._print_Piecewise(expr) and returns: code