fslaborg / RProvider

Access R packages from F#
http://fslab.org/RProvider/
Other
235 stars 69 forks source link

=> operator for more intuitive passing of parameters to R functions #257

Closed AndrewIOM closed 1 year ago

AndrewIOM commented 2 years ago

Proposed Changes

Following discussion in #183, adds the proposed => operator in a RProvider.Operators module. The => operator can be used instead of namedParams to define a parameter list to pass to an R function:

R.plot([
    "x" => widgets
    "type" => "o"
    "col" => "blue"
    "ylim" => [0; 25] ])

R.plot [ "x" => Xs; "y" => Ys ]

... instead of:

R.plot(
    namedParams [   
        "x", box widgets; 
        "type", box "o"; 
        "col", box "blue";
        "ylim", box [0; 25] ])

R.plot (namedParams [ "x", box Xs; "y", box Ys ])

I added an additional overload to R functions that takes a list of string obj rather than a dictionary of string obj to enable use of the => operator. The dictionary option is still available so that the change is not breaking.

Documentation has been updated to use the Operators module and =>.

Types of changes

What types of changes does your code introduce to RProvider? Put an x in the boxes that apply

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Further comments