处理非常大的expand.grid?(Dealing with very large expand.grid?)
我给了31个二元变量,为了简单起见,我们称它们为
x_1, ..., x_31
。每个
X_i = c(0, 1)
。我需要构建一个选项树。 我为此使用了expand.grid,但是我的服务器抛出一个错误:
错误:无法分配大小为16.0 Gb的向量。
我知道我可以
sparsify
这个,但我该如何处理大尺寸?使用
sparsify
会提供相同的错误消息,但使用8 Gb
。请指教。
I am given 31 binary variables, for simplicity let's call them
x_1, ..., x_31
.Each
X_i = c(0, 1)
.I need to build a tree of options. I have used expand.grid for this but my server throws an error:
Error: cannot allocate vector of size 16.0 Gb.
I am aware that I can
sparsify
this but how can I deal with the large size?Using
sparsify
gives the same error message but with8 Gb
.Please advise.
原文:https://stackoverflow.com/questions/50665119
满意答案
您可以使用条件聚合简化事情:
SELECT ThingName, count(ItemNumber) as TotalItems, count(case when ItemStatus='Red' then ItemNumber end) as RedItems, count(case when ItemStatus='Blue' then ItemNumber end) as BlueItems FROM Things GROUP BY ThingName;
因此,不使用使用
CASE
表达式的子查询来获取Total,Red,Blue项的计数,而是直接在聚合函数内使用CASE
表达式,在这种情况下为COUNT
。You can simplify things using conditional aggregation:
SELECT ThingName, count(ItemNumber) as TotalItems, count(case when ItemStatus='Red' then ItemNumber end) as RedItems, count(case when ItemStatus='Blue' then ItemNumber end) as BlueItems FROM Things GROUP BY ThingName;
Hence, instead of using a subquery that uses a
CASE
expression to get count of Total, Red, Blue items, use theCASE
expression directly inside the aggregate function,COUNT
in this case.
相关问答
更多如何在postgres中进行条件聚合?(How to do conditional aggregation in postgres?)
条件聚合引用表而不是手动输入(Conditional aggregation referencing table instead of manual entry)
mongodb聚合中的多个条件和(Multiple conditional sums in mongodb aggregation)
MongoDb聚合中的条件展开?(Conditional unwind in MongoDb's aggregation?)
MySQL条件文本聚合(MySQL conditional text aggregation)
数据表聚合中的条件因子水平选择(Conditional Factor Level Selection in Aggregation of Data Table)
Elasticsearch中多字段的条件聚合(Conditional aggregation on multi-field in Elasticsearch)
使用JOIN进行条件聚合?(Conditional aggregation with JOIN?)
如何在Mongodb的聚合中添加条件操作?(How to add conditional operation in Mongodb's Aggregation?)
多列条件聚合(Multi-column Conditional Aggregation)
相关文章
更多ext grid
extjs4 editor grid 问题
Ext 禁用grid
Ext grid分页的问题
怎样改变 Ext grid 的字体大小
Ext grid 出现checkbox和图标移位的问题(在IE)
Ext的例子 中有关grid渲染数据的问题
Extjs 怎样将grid的record转换成Json串,然后post到下个画面?
jqgrid addRowData在grid里没有其他行时可以正确添加,有行时则不能添加
采用了数据库分页技术的grid. 当点了选择全部之后, 怎么才能不让表格不能翻到下一页?
最新问答
更多python的访问器方法有哪些
使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
透明度错误IE11(Transparency bug IE11)
linux的基本操作命令。。。
响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
元素上的盒子阴影行为(box-shadow behaviour on elements)
它看起来像只在Windows上的Chrome的错误。 我在Google Canary (Chrome 63)中也进行了测试,问题依然存在,所以有可能它不会很快修复。 这个问题是由overflow: auto引起的overflow: auto ,在你的情况下,它可以很容易地通过删除或设置为可见(默认)来解决。 但是 ,将鼠标悬停在右侧(顶部和底部)时,会出现滚动条。 一个解决方案可以设置overflow: hidden的身体,所以预期的结果是所需的。 我想指出,这不是一个很好的解决方案,但我建议暂
Laravel检查是否存在记录(Laravel Checking If a Record Exists)
这取决于您是否要以后与用户合作,或仅检查是否存在。 如果要使用用户对象(如果存在): $user = User::where('email', '=', Input::get('email'))->first(); if ($user === null) { // user doesn't exist } 如果你只想检查 if (User::where('email', '=', Input::get('email'))->count() > 0) { // user found
设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
$scope.getData= function () { var reader = new FileReader(); reader.onload = $('input[type=file]')[0].files; var img = new Image(); img.src =(reader.onload[0].result); img.onload = function() { if(this.width > 640
Copyright ©2023
peixunduo.com All
Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!
Laravel检查是否存在记录(Laravel Checking If a Record Exists)
设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!