[R] Symbolic equations to R code?

Rainer M Krug Rainer at krugs.de
Fri Nov 21 09:21:46 CET 2014

```Scott Rifkin <sarifkin at ucsd.edu> writes:

> Ista,
>
> On the one hand I'd like it to be as flexible as possible so the
> students could really come up with whatever they like.  On the other
> hand, restricting their choices probably would make it easier to do
> the backend.  The goal would be to get them to realize that the
> apparatus of hypothesis testing (when done via
> simulation/randomization techniques) doesn't depend on what the
> statistic is. The flow of steps is the same whether the statistic is a
> mean, variance, or their own kooky thing. Obviously this isn't the end
> of the story - what the statistic is actually describing is also a
> crucial component to interpreting the results of a hypothesis test,
> but I think it teaches an important pedagogical point about where
> statistics come from and that if they find themselves in a situation
> in the future where they need to make up their own, then that is
> perfectly okay.
>
> So they could make up ones like:  arctan( (max({x})^2)/ (min({x})^2)
> )-3), max({x})-min({x}), sum from i to n of (x_i - 25th%ile({x}) )^3)
> [that might be tricky to write in a standard equation editor]
> none of these is hard to write in R, but translating from an equation
> editor might be.
>
> Perhaps the best solution is (as Alan suggests below) to write a Shiny
> function builder myself so that I can control the whole process and
> make sure that they can't enter anything that would break the backend.
> Or to have them learn the rudiments of writing equations in R so that
> it bypasses the whole process.

Teach them to write equations in R will make them more used to the
logic in R and make them feel easier to use R.

On the other hand, a converter from LaTeX equations to R formulas and
back would be quite a useful thing for e.g. documentation and paper
writing (e.g a formula entered in LaTeX could be immediately tested in
R) - but I guess that would be quite a complex task...

Cheers,

Rainer

>
> Thanks,
> Scott
>
>
>
> On 11/19/14 1:52 PM, Ista Zahn wrote:
>> Hi Scott,
>>
>> Can you give a couple of examples of the equations you have in mind
>> along with how those should be translated to R?
>>
>> Thanks,
>> Ista
>>
>

--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 494 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20141121/e4624983/attachment.bin>
```