0

I would like to convert Mathematica code to R code. For example,

4/(-1 + δ) + (-1 + δ) Subscript[P, R]

The above is a copy version from Matematica. But I would like to type this one in R such as:

4/(-1 + Delta) + (-1 + Delta)*PR

Of course, the example is very simple to convert directly to R, but some complicated equations are not easy to covert it.

Could you please let me know how to automatically convert to R code?

MarcoB
  • 67,153
  • 18
  • 91
  • 189
Sam Kim
  • 1
  • 1
  • 2
    Do you just mean that you want the special symbols to resolve to a plain name and subscripts to unwrap as if there were no subscript? – b3m2a1 Jul 03 '18 at 18:03
  • Yes and * or / . Mathematica usually doesn't need to have * . But R should have it! – Sam Kim Jul 03 '18 at 18:49
  • 3
    My suggestion is to start with a simple pattern-matching replacement of Subscript via ReplaceAll then hit the resultant expression with ToString[..., CForm] – b3m2a1 Jul 03 '18 at 20:11
  • Thank you so much b3m2a1! – Sam Kim Jul 05 '18 at 20:15

0 Answers0