Generating a very large matrix of string combinations using combn() and bigmemory package

前端 未结 3 1800
星月不相逢
星月不相逢 2020-12-16 05:30

I have a vector x of 1,344 unique strings. I want to generate a matrix that gives me all possible groups of three values, regardless of order, and export that to a csv.

3条回答
  •  不知归路
    2020-12-16 06:27

    At a first approximation, every algorithm trades off storage for speed.

    You have hit a boundary trying to preallocate your fully enumerated combination matrix. So maybe you should try not to preallocate this matrix but to try, say,

    1. If you think you need the combinations, calculate them somewhere else and store them in a simple db (or, heck, flat file) and look them up -- 9 gb saved

    2. Take advantage of open source, read the code to combn() and modify it into a client-server thingy: given a call with index number N, it will loop and return the Nth entry. Not efficient, but possibly more easily feasible.

提交回复
热议问题