#12948: Get R interface to properly accept keywords
--------------------------+-------------------------------------------------
Reporter: kcrisman | Owner: was
Type: defect | Status: new
Priority: major | Milestone: sage-5.1
Component: interfaces | Keywords: r-project
Work issues: | Report Upstream: N/A
Reviewers: | Authors:
Merged in: | Dependencies:
Stopgaps: |
--------------------------+-------------------------------------------------
One of many example of how this doesn't work. In order to do
{{{
subset(cars, select = speed)
}}}
you need to do the not very Sage-like
{{{
sage: r.new("subset(cars,select=speed)")
}}}
because otherwise you have
{{{
sage: r.subset("cars",select='speed')
Error: object 'sage2' not found
sage: r.subset(r.cars,select='speed')
['sage2']
}}}
See [http://ask.sagemath.org/question/1415/is-there-more-documentation-
about-how-to-call-r-in this ask.sagemath question] for this example, but
this happens a lot with keywords, you almost have to just substitute them
in by hand.
Diagnosis: in R interface we have
{{{
def function_call(self, function, args=None, kwds=None):
args, kwds = self._convert_args_kwds(args, kwds)
self._check_valid_function_name(function)
return self.new("%s(%s)"%(function, ",".join([s.name() for s in
args] +
[self._sage_to_r_name(key)+'='+kwds[key].name() for key in kwds ] )))
}}}
and notice that `interface._convert_arg_kwds` "Converts all of the args
and kwds to be elements of this interface.", which in this case is
inappropriate.
I'm not sure what the best fix is, but at any rate changing to
{{{
# args, kwds = self._convert_args_kwds(args, kwds)
self._check_valid_function_name(function)
return self.new("%s(%s)"%(function, ",".join([s for s in args] +
[self._sage_to_r_name(key)+'='+kwds[key] for key in kwds ] )))
}}}
allows
{{{
sage: r.subset("cars",select='speed')
}}}
to work, though it can't be a final solution since it breaks
{{{
sage: r.subset(r.cars,select='speed')
}}}
which should also work, in principle.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12948>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.