这是我的数据文件。
Location.Name Item.Description Sort.In.Date OrderedQty
HC Overijse Pro B 731 7/1/2015 2
HC Overijse Pro B 731 8/3/2015 2
HC Overijse Pro B 931 8/27/2015 1
HC Overijse Pro B 933 6/24/2015 2
HC Overijse Pro B 933 7/22/2015 2
HC Overijse Pro B 933 7/29/2015 1
HC Overijse Pro R 731 6/16/2015 2
HC Overijse Pro R 731 8/3/2015 2
Hannah Thieuw Pro B 933 7/14/2015 2
Hannah Thieuw Pro R 731 8/14/2015 2
HC Asse Pro B 731 6/12/2015 2
HC Asse Pro B 931 6/12/2015 2
HC Asse Pro B 933 6/4/2015 2
HC Asse Pro R 731 6/8/2015 2
HC Asse Pro R 731 6/10/2015 2
HC Asse Pro R 731 6/17/2015 2
HC Asse Pro R 731 7/9/2015 2
HC Asse Pro R 731 7/27/2015 2
HC Asse Pro R 732 6/16/2015 2
我的问题是如何计算6/1 / 20105-> 2015年8月31日期间(没有周末)的每日/每周平均订购数量。每个位置和每个产品。所以我必须找到一种方法将零插入数据集来计算平均值。 (这将是一个小值)。我还需要展台开发。我使用此代码计算每个订单的平均orderdQty和2个订单之间的时间。
fe <- fe[order(fe$Item.Description,fe$Location.Name,fe$Sort.In.Date), ]
sfe<-dlply(fe, .(fe$Item.Description,fe$Location.Name))
fe$DayBetween <- unlist(sapply(seq_along(sfe), function(x) diff(as.Date(c(NA, as.Date(sfe[[x]][,3] , format="%d/%m/%Y") ))) ))
FilteredExport<-fe
remove(fe)
results<-ddply(FilteredExport, .(Location.Code,Location.Name,Item.Description),summarize,
N=length(Item.Description), AverageQty = mean(OrderedQty),sdAverageQty=sd(OrderedQty) , AvgTimeBetweenOrder = mean(DayBetween,na.rm=TRUE),sdAvgTimeBetweenOrder=sd(DayBetween,na.rm=TRUE))
以下是我的数据输入:
structure(list(Location.Name = c("HC Overijse", "HC Overijse",
"HC Overijse", "HC Overijse", "HC Overijse", "HC Overijse", "HC Overijse",
"HC Overijse", "Hannah Thieuw", "Hannah Thieuw", "HC Asse", "HC Asse",
"HC Asse", "HC Asse", "HC Asse", "HC Asse", "HC Asse", "HC Asse",
"HC Asse"), Item.Description = c("Pro B 731", "Pro B 731", "Pro B 931",
"Pro B 933", "Pro B 933", "Pro B 933", "Pro R 731", "Pro R 731",
"Pro B 933", "Pro R 731", "Pro B 731", "Pro B 931", "Pro B 933",
"Pro R 731", "Pro R 731", "Pro R 731", "Pro R 731", "Pro R 731",
"Pro R 732"), Sort.In.Date = structure(c(16617, 16650, 16674,
16610, 16638, 16645, 16602, 16650, 16630, 16661, 16598, 16598,
16590, 16594, 16596, 16603, 16625, 16643, 16602), class = "Date"),
OrderedQty = c(2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L)), .Names = c("Location.Name",
"Item.Description", "Sort.In.Date", "OrderedQty"), row.names = c(NA,
-19L), class = "data.frame")
答案 0 :(得分:0)
List<State> getNeighbors(State s) {
List<State> neighbors = new ArrayList<State>();
for (Brick b : s.bricks) {
// if you can move the brick up
// create new state new_state_up as you update 'a'
// and 'bricks' and simply add it to neighbors.
// do the same for the rest of the directions
}
return neighbors;
}