Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Sage列表转换为R列表_R_List_Sage_Rdata - Fatal编程技术网

将Sage列表转换为R列表

将Sage列表转换为R列表,r,list,sage,rdata,R,List,Sage,Rdata,我有一个sage列表列表,它是在R列表列表(转换为sage格式)上应用某些函数的结果 代码如下所示: %r my_r_list<-load("my_r_list.RData") for d in range(D): for s in range(S): for c in range(C): my_sage_list[d][s][c] = ("my_r_list")[[d+1]][[s+1]][[c+1]]._sage_()

我有一个sage列表列表,它是在R列表列表(转换为sage格式)上应用某些函数的结果

代码如下所示:

%r
my_r_list<-load("my_r_list.RData")

for d in range(D):
    for s in range(S):
        for c in range(C):
            my_sage_list[d][s][c] = ("my_r_list")[[d+1]][[s+1]][[c+1]]._sage_()
            output_my_sage_list[d][s][c] = some_function(my_sage_list[d][s][c])

我想将
output\u d
转换为R列表

这里的关键是您的语句

我还尝试了简单的
output\u my\u r\u list=r(output\u my\u sage\u list)
,它没有给出错误,但输出不正确,因为执行
output\u my\u r\u list[0][0]
不会给出列表的最后一级,而是直接给出一些值

Sage实际上记录了它将使列表成为一个串联列表,或者更恰当地说是一个R向量:

这是直接的,大概(通过一些嵌套过程)甚至仅仅来自它:

The further assignment

> y <- c(x, 0, x)

would create a vector y with 11 entries consisting of two copies of 
with a zero in the middle place.
然后R的行为如下,这是递归的,它生成一个向量向量

解决这个问题的一个方法是返回
”列表(
),另一个方法是尝试使用
r.eval(“列表(某物)”)
,但我在这方面没有太多成功经验

当然,如果能找到一种更容易处理这一问题的方法,并朝着Sage(我不知道是否成功)的方向发展,那就太好了

    sage: x = r([10.4,5.6,3.1,6.4,21.7]); x
    [1] 10.4  5.6  3.1  6.4 21.7

The following assignment creates a vector $y$ with 11 entries which
consists of two copies of $x$ with a 0 in between::

    sage: y = r([x,0,x]); y
    [1] 10.4  5.6  3.1  6.4 21.7  0.0 10.4  5.6  3.1  6.4 21.7
The further assignment

> y <- c(x, 0, x)

would create a vector y with 11 entries consisting of two copies of 
with a zero in the middle place.
def _left_list_delim(self):
    return "c("