I am trying to create a matrix with two combinations of the same vector that sum up to 2300. I am using thecombn
function in R, see the code below:
vector <- 400:1900
combinations <- combn(vector, 2, function(x) subset(x, sum(x)==2300))
Unfortunately, this code is not working. I get the following error:
Error in combn(r2, 2, function(x) subset(x, sum(x) == 2300)) :
dims [product 1125750] do not match the length of object [0]
Do anyone know what i did wrong? Many thanks,
Gion