You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 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
You need to use double quotes for strings when passing them into the interface. Otherwise, speed will be treated as an "identifier" rather than a string. There were some thought on changing this, but it is backwards incompatible and should be made consistent across interfaces.
You need to use double quotes for strings when passing them into the interface. Otherwise, speed will be treated as an "identifier" rather than a string. There were some thought on changing this, but it is backwards incompatible and should be made consistent across interfaces.
Hmm, thanks. Somehow I figured this out a long time ago but completely forgot - at the very least we need better doc! So is this true for all the interfaces?
Also, you should post these answers on the ask.sagemath.org question. Since they're yours :-)
So I am repurposing this ticket to much better documentation of this issue, including the examples from that wiki page, and then #2963 can stay for possible changing this situation.
One of many example of how this doesn't work. In order to do
you need to do the not very Sage-like
because otherwise you have
See 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
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
allows
to work, though it can't be a final solution since it breaks
which should also work, in principle.
Component: interfaces
Keywords: r-project
Issue created by migration from https://trac.sagemath.org/ticket/12948
The text was updated successfully, but these errors were encountered: