我需要生成一个固定长度的列表,以便在超过长度时,删除列表中最早的项目。这可以通过在Python中使用transform: translate(x,y) //to modify x and y axis
transform: translateX(x) //to modify only x axis
transform: translateY(y) //to modify only y axis
(类似列表的容器,两端都有快速追加和弹出)来实现。
我想知道是否有R等价的python的deque
?
我了解deque
和dequer
个库,但它们都没有提供固定长度的队列。
提前致谢。
答案 0 :(得分:0)
不确定这是最好的方法,但根据@J_F的评论,我写了以下函数:
List <- vector("list", Length)
deque <- function(List, x)
{
Length = length(List)
List <- c(List, x)
if (length(List) > Length)
{
List[1] <- NULL
}
return(List)
}
答案 1 :(得分:0)
不确定你究竟要做什么,但是r有一个MongoDB的接口,它有限制集合。你可能想看一下。