Conditional Matrix or Combinations in R












0















I have 7 vectors :



vector1 = c(9,8,7,6,5)
vector2 = c(10,20,30)
vector3=c(19,27,34,40,45)
vector4=c(29,37,44)
vector5=c(39,47)
vector6=c(28,36)
vector7=c(13,42)
vector=c(vector1,vector2,vector3,vector4,vector5,vector6,vector7)

co = expand.grid(vector,vector,vector,vector,vector,vector)


I need a 6-variable combination table of the above vectors, but the value in each vector should not be repeated more than 2 times in each row of this table and the same numbers should not be present in each row. For example:



V1 V1 V2 V3 V4 V7



V1 V3 V4 V5 V6 V7



How can I do that?



V1 = c (9,8,7,6,5)
V2 = c (10,20,30)
V3 = c (19,27,34,40,45)
V4 = c (29,37,44)
V5 = c (39.47)
V6 = c (28.36)
V7 = c (13,25,42)


I have 7 vector groups. I want to list them in combinations with 6 variables. There should not be more than 2 members from each row of these 7 groups.



As a second condition,



x1 = 1: 9
x2 = 10:19
x3 = 20:29
x4 = 30: 39
x5 = 40:49


I have groups as seen above. There should not be more than 3 members in the x1, x2, x3, x4 or x5 group range in each row in the combination list.



For example: In a combination of 2 3 5 7 19 25, the number of x1 members should not be in the combination list because they are more than 3.










share|improve this question

























  • Do you need every combination that matches those requirements? Or just a way to sample from them? (And order doesn't matter, right?)

    – Gregor
    Nov 13 '18 at 22:56











  • Try combn(paste0("V", c(1:7, 1:7)), m = 6). Or maybe unique(lapply(combn(paste0("V", c(1:7, 1:7)), m = 6, simplify = FALSE), sort))

    – Gregor
    Nov 13 '18 at 22:58








  • 1





    I'm not quite sure what you mean by "and the same numbers should not be present in each row", but my above comment seems like what you want?

    – Gregor
    Nov 13 '18 at 23:01











  • Thanks Gregor. It works but I have more questions to solve.

    – Tim
    Nov 14 '18 at 6:47








  • 1





    @Tim , could you edit your question with a smaller example and include the desired output along with what you have tried. As it stands, together with your comments, it is unclear what you are asking.

    – Joseph Wood
    Nov 14 '18 at 11:10
















0















I have 7 vectors :



vector1 = c(9,8,7,6,5)
vector2 = c(10,20,30)
vector3=c(19,27,34,40,45)
vector4=c(29,37,44)
vector5=c(39,47)
vector6=c(28,36)
vector7=c(13,42)
vector=c(vector1,vector2,vector3,vector4,vector5,vector6,vector7)

co = expand.grid(vector,vector,vector,vector,vector,vector)


I need a 6-variable combination table of the above vectors, but the value in each vector should not be repeated more than 2 times in each row of this table and the same numbers should not be present in each row. For example:



V1 V1 V2 V3 V4 V7



V1 V3 V4 V5 V6 V7



How can I do that?



V1 = c (9,8,7,6,5)
V2 = c (10,20,30)
V3 = c (19,27,34,40,45)
V4 = c (29,37,44)
V5 = c (39.47)
V6 = c (28.36)
V7 = c (13,25,42)


I have 7 vector groups. I want to list them in combinations with 6 variables. There should not be more than 2 members from each row of these 7 groups.



As a second condition,



x1 = 1: 9
x2 = 10:19
x3 = 20:29
x4 = 30: 39
x5 = 40:49


I have groups as seen above. There should not be more than 3 members in the x1, x2, x3, x4 or x5 group range in each row in the combination list.



For example: In a combination of 2 3 5 7 19 25, the number of x1 members should not be in the combination list because they are more than 3.










share|improve this question

























  • Do you need every combination that matches those requirements? Or just a way to sample from them? (And order doesn't matter, right?)

    – Gregor
    Nov 13 '18 at 22:56











  • Try combn(paste0("V", c(1:7, 1:7)), m = 6). Or maybe unique(lapply(combn(paste0("V", c(1:7, 1:7)), m = 6, simplify = FALSE), sort))

    – Gregor
    Nov 13 '18 at 22:58








  • 1





    I'm not quite sure what you mean by "and the same numbers should not be present in each row", but my above comment seems like what you want?

    – Gregor
    Nov 13 '18 at 23:01











  • Thanks Gregor. It works but I have more questions to solve.

    – Tim
    Nov 14 '18 at 6:47








  • 1





    @Tim , could you edit your question with a smaller example and include the desired output along with what you have tried. As it stands, together with your comments, it is unclear what you are asking.

    – Joseph Wood
    Nov 14 '18 at 11:10














0












0








0








I have 7 vectors :



vector1 = c(9,8,7,6,5)
vector2 = c(10,20,30)
vector3=c(19,27,34,40,45)
vector4=c(29,37,44)
vector5=c(39,47)
vector6=c(28,36)
vector7=c(13,42)
vector=c(vector1,vector2,vector3,vector4,vector5,vector6,vector7)

co = expand.grid(vector,vector,vector,vector,vector,vector)


I need a 6-variable combination table of the above vectors, but the value in each vector should not be repeated more than 2 times in each row of this table and the same numbers should not be present in each row. For example:



V1 V1 V2 V3 V4 V7



V1 V3 V4 V5 V6 V7



How can I do that?



V1 = c (9,8,7,6,5)
V2 = c (10,20,30)
V3 = c (19,27,34,40,45)
V4 = c (29,37,44)
V5 = c (39.47)
V6 = c (28.36)
V7 = c (13,25,42)


I have 7 vector groups. I want to list them in combinations with 6 variables. There should not be more than 2 members from each row of these 7 groups.



As a second condition,



x1 = 1: 9
x2 = 10:19
x3 = 20:29
x4 = 30: 39
x5 = 40:49


I have groups as seen above. There should not be more than 3 members in the x1, x2, x3, x4 or x5 group range in each row in the combination list.



For example: In a combination of 2 3 5 7 19 25, the number of x1 members should not be in the combination list because they are more than 3.










share|improve this question
















I have 7 vectors :



vector1 = c(9,8,7,6,5)
vector2 = c(10,20,30)
vector3=c(19,27,34,40,45)
vector4=c(29,37,44)
vector5=c(39,47)
vector6=c(28,36)
vector7=c(13,42)
vector=c(vector1,vector2,vector3,vector4,vector5,vector6,vector7)

co = expand.grid(vector,vector,vector,vector,vector,vector)


I need a 6-variable combination table of the above vectors, but the value in each vector should not be repeated more than 2 times in each row of this table and the same numbers should not be present in each row. For example:



V1 V1 V2 V3 V4 V7



V1 V3 V4 V5 V6 V7



How can I do that?



V1 = c (9,8,7,6,5)
V2 = c (10,20,30)
V3 = c (19,27,34,40,45)
V4 = c (29,37,44)
V5 = c (39.47)
V6 = c (28.36)
V7 = c (13,25,42)


I have 7 vector groups. I want to list them in combinations with 6 variables. There should not be more than 2 members from each row of these 7 groups.



As a second condition,



x1 = 1: 9
x2 = 10:19
x3 = 20:29
x4 = 30: 39
x5 = 40:49


I have groups as seen above. There should not be more than 3 members in the x1, x2, x3, x4 or x5 group range in each row in the combination list.



For example: In a combination of 2 3 5 7 19 25, the number of x1 members should not be in the combination list because they are more than 3.







r matrix conditional combinations






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 21:49







Tim

















asked Nov 13 '18 at 22:49









TimTim

12




12













  • Do you need every combination that matches those requirements? Or just a way to sample from them? (And order doesn't matter, right?)

    – Gregor
    Nov 13 '18 at 22:56











  • Try combn(paste0("V", c(1:7, 1:7)), m = 6). Or maybe unique(lapply(combn(paste0("V", c(1:7, 1:7)), m = 6, simplify = FALSE), sort))

    – Gregor
    Nov 13 '18 at 22:58








  • 1





    I'm not quite sure what you mean by "and the same numbers should not be present in each row", but my above comment seems like what you want?

    – Gregor
    Nov 13 '18 at 23:01











  • Thanks Gregor. It works but I have more questions to solve.

    – Tim
    Nov 14 '18 at 6:47








  • 1





    @Tim , could you edit your question with a smaller example and include the desired output along with what you have tried. As it stands, together with your comments, it is unclear what you are asking.

    – Joseph Wood
    Nov 14 '18 at 11:10



















  • Do you need every combination that matches those requirements? Or just a way to sample from them? (And order doesn't matter, right?)

    – Gregor
    Nov 13 '18 at 22:56











  • Try combn(paste0("V", c(1:7, 1:7)), m = 6). Or maybe unique(lapply(combn(paste0("V", c(1:7, 1:7)), m = 6, simplify = FALSE), sort))

    – Gregor
    Nov 13 '18 at 22:58








  • 1





    I'm not quite sure what you mean by "and the same numbers should not be present in each row", but my above comment seems like what you want?

    – Gregor
    Nov 13 '18 at 23:01











  • Thanks Gregor. It works but I have more questions to solve.

    – Tim
    Nov 14 '18 at 6:47








  • 1





    @Tim , could you edit your question with a smaller example and include the desired output along with what you have tried. As it stands, together with your comments, it is unclear what you are asking.

    – Joseph Wood
    Nov 14 '18 at 11:10

















Do you need every combination that matches those requirements? Or just a way to sample from them? (And order doesn't matter, right?)

– Gregor
Nov 13 '18 at 22:56





Do you need every combination that matches those requirements? Or just a way to sample from them? (And order doesn't matter, right?)

– Gregor
Nov 13 '18 at 22:56













Try combn(paste0("V", c(1:7, 1:7)), m = 6). Or maybe unique(lapply(combn(paste0("V", c(1:7, 1:7)), m = 6, simplify = FALSE), sort))

– Gregor
Nov 13 '18 at 22:58







Try combn(paste0("V", c(1:7, 1:7)), m = 6). Or maybe unique(lapply(combn(paste0("V", c(1:7, 1:7)), m = 6, simplify = FALSE), sort))

– Gregor
Nov 13 '18 at 22:58






1




1





I'm not quite sure what you mean by "and the same numbers should not be present in each row", but my above comment seems like what you want?

– Gregor
Nov 13 '18 at 23:01





I'm not quite sure what you mean by "and the same numbers should not be present in each row", but my above comment seems like what you want?

– Gregor
Nov 13 '18 at 23:01













Thanks Gregor. It works but I have more questions to solve.

– Tim
Nov 14 '18 at 6:47







Thanks Gregor. It works but I have more questions to solve.

– Tim
Nov 14 '18 at 6:47






1




1





@Tim , could you edit your question with a smaller example and include the desired output along with what you have tried. As it stands, together with your comments, it is unclear what you are asking.

– Joseph Wood
Nov 14 '18 at 11:10





@Tim , could you edit your question with a smaller example and include the desired output along with what you have tried. As it stands, together with your comments, it is unclear what you are asking.

– Joseph Wood
Nov 14 '18 at 11:10












1 Answer
1






active

oldest

votes


















0














Here's an idea. It's not a great answer because I didn't fully test it, but I think it should work. It's rather inefficient, and I didn't have the patience to let it run long enough to complete.



y = rep(vector, 2)
result = unique(
lapply(
Filter(f = function(x) !anyDuplicated(x),
combn(y, m = 6, simplify = FALSE)
),
sort)
)


Explanation: make two copies of all your inputs in a vector. Generate all combinations choosing 6 elements. Filter out any results with duplicates. Sort them so they are in a consistent order. Keep the unique combinations.



This is inefficient because the first step will generate choose(length(y), 6) ~= 7M combinations, which we then have to whittle down to (I think) 166,638 final combinations. But it's the simplest way I can think of to code your requirements.






share|improve this answer
























  • Thank you for your attention @Gregor but that's not what I want. This code prevents repeated combinations, but does not provide the two conditions I mentioned above. I want vector1,2,3,4,5,6,7 members not to repeat more than 2 times in the same row and 1: 9, 10: 19 ..... to not repeat the numbers more than 3 times. As an example: 1. If the condition is v1 = c (14,15,17,19) I want to have at most 2 of these numbers on each line. As an example: I don't want to have 11,13,15,17 on the same line as the 2nd condition.

    – Tim
    Nov 14 '18 at 21:23











  • Hmm, I guess I missed your edit and only met the first condition. I'll leave the partial answer as a starting place for anyone who wants to work more on it.

    – Gregor
    Nov 14 '18 at 21:32











  • Thank you @Gregor

    – Tim
    Nov 14 '18 at 21:36











  • Also, I'm confused that 44 is in both V4 and V7. How does that work? Is it okay for 44 to repeat because of that? My answer certainly doesn't take that into account.

    – Gregor
    Nov 14 '18 at 21:36











  • In fact, 44 of the two vectors is not a problem. Of course, the number 44 must not be 2 on the same row. I wrote the data set as an example. I can change 44. In fact, 44 was not supposed to be on 2 vector. However, 3 numbers with v4 and v7 should not have more than 2 members on the same row.

    – Tim
    Nov 14 '18 at 21:48













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290688%2fconditional-matrix-or-combinations-in-r%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Here's an idea. It's not a great answer because I didn't fully test it, but I think it should work. It's rather inefficient, and I didn't have the patience to let it run long enough to complete.



y = rep(vector, 2)
result = unique(
lapply(
Filter(f = function(x) !anyDuplicated(x),
combn(y, m = 6, simplify = FALSE)
),
sort)
)


Explanation: make two copies of all your inputs in a vector. Generate all combinations choosing 6 elements. Filter out any results with duplicates. Sort them so they are in a consistent order. Keep the unique combinations.



This is inefficient because the first step will generate choose(length(y), 6) ~= 7M combinations, which we then have to whittle down to (I think) 166,638 final combinations. But it's the simplest way I can think of to code your requirements.






share|improve this answer
























  • Thank you for your attention @Gregor but that's not what I want. This code prevents repeated combinations, but does not provide the two conditions I mentioned above. I want vector1,2,3,4,5,6,7 members not to repeat more than 2 times in the same row and 1: 9, 10: 19 ..... to not repeat the numbers more than 3 times. As an example: 1. If the condition is v1 = c (14,15,17,19) I want to have at most 2 of these numbers on each line. As an example: I don't want to have 11,13,15,17 on the same line as the 2nd condition.

    – Tim
    Nov 14 '18 at 21:23











  • Hmm, I guess I missed your edit and only met the first condition. I'll leave the partial answer as a starting place for anyone who wants to work more on it.

    – Gregor
    Nov 14 '18 at 21:32











  • Thank you @Gregor

    – Tim
    Nov 14 '18 at 21:36











  • Also, I'm confused that 44 is in both V4 and V7. How does that work? Is it okay for 44 to repeat because of that? My answer certainly doesn't take that into account.

    – Gregor
    Nov 14 '18 at 21:36











  • In fact, 44 of the two vectors is not a problem. Of course, the number 44 must not be 2 on the same row. I wrote the data set as an example. I can change 44. In fact, 44 was not supposed to be on 2 vector. However, 3 numbers with v4 and v7 should not have more than 2 members on the same row.

    – Tim
    Nov 14 '18 at 21:48


















0














Here's an idea. It's not a great answer because I didn't fully test it, but I think it should work. It's rather inefficient, and I didn't have the patience to let it run long enough to complete.



y = rep(vector, 2)
result = unique(
lapply(
Filter(f = function(x) !anyDuplicated(x),
combn(y, m = 6, simplify = FALSE)
),
sort)
)


Explanation: make two copies of all your inputs in a vector. Generate all combinations choosing 6 elements. Filter out any results with duplicates. Sort them so they are in a consistent order. Keep the unique combinations.



This is inefficient because the first step will generate choose(length(y), 6) ~= 7M combinations, which we then have to whittle down to (I think) 166,638 final combinations. But it's the simplest way I can think of to code your requirements.






share|improve this answer
























  • Thank you for your attention @Gregor but that's not what I want. This code prevents repeated combinations, but does not provide the two conditions I mentioned above. I want vector1,2,3,4,5,6,7 members not to repeat more than 2 times in the same row and 1: 9, 10: 19 ..... to not repeat the numbers more than 3 times. As an example: 1. If the condition is v1 = c (14,15,17,19) I want to have at most 2 of these numbers on each line. As an example: I don't want to have 11,13,15,17 on the same line as the 2nd condition.

    – Tim
    Nov 14 '18 at 21:23











  • Hmm, I guess I missed your edit and only met the first condition. I'll leave the partial answer as a starting place for anyone who wants to work more on it.

    – Gregor
    Nov 14 '18 at 21:32











  • Thank you @Gregor

    – Tim
    Nov 14 '18 at 21:36











  • Also, I'm confused that 44 is in both V4 and V7. How does that work? Is it okay for 44 to repeat because of that? My answer certainly doesn't take that into account.

    – Gregor
    Nov 14 '18 at 21:36











  • In fact, 44 of the two vectors is not a problem. Of course, the number 44 must not be 2 on the same row. I wrote the data set as an example. I can change 44. In fact, 44 was not supposed to be on 2 vector. However, 3 numbers with v4 and v7 should not have more than 2 members on the same row.

    – Tim
    Nov 14 '18 at 21:48
















0












0








0







Here's an idea. It's not a great answer because I didn't fully test it, but I think it should work. It's rather inefficient, and I didn't have the patience to let it run long enough to complete.



y = rep(vector, 2)
result = unique(
lapply(
Filter(f = function(x) !anyDuplicated(x),
combn(y, m = 6, simplify = FALSE)
),
sort)
)


Explanation: make two copies of all your inputs in a vector. Generate all combinations choosing 6 elements. Filter out any results with duplicates. Sort them so they are in a consistent order. Keep the unique combinations.



This is inefficient because the first step will generate choose(length(y), 6) ~= 7M combinations, which we then have to whittle down to (I think) 166,638 final combinations. But it's the simplest way I can think of to code your requirements.






share|improve this answer













Here's an idea. It's not a great answer because I didn't fully test it, but I think it should work. It's rather inefficient, and I didn't have the patience to let it run long enough to complete.



y = rep(vector, 2)
result = unique(
lapply(
Filter(f = function(x) !anyDuplicated(x),
combn(y, m = 6, simplify = FALSE)
),
sort)
)


Explanation: make two copies of all your inputs in a vector. Generate all combinations choosing 6 elements. Filter out any results with duplicates. Sort them so they are in a consistent order. Keep the unique combinations.



This is inefficient because the first step will generate choose(length(y), 6) ~= 7M combinations, which we then have to whittle down to (I think) 166,638 final combinations. But it's the simplest way I can think of to code your requirements.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 20:14









GregorGregor

64.5k990172




64.5k990172













  • Thank you for your attention @Gregor but that's not what I want. This code prevents repeated combinations, but does not provide the two conditions I mentioned above. I want vector1,2,3,4,5,6,7 members not to repeat more than 2 times in the same row and 1: 9, 10: 19 ..... to not repeat the numbers more than 3 times. As an example: 1. If the condition is v1 = c (14,15,17,19) I want to have at most 2 of these numbers on each line. As an example: I don't want to have 11,13,15,17 on the same line as the 2nd condition.

    – Tim
    Nov 14 '18 at 21:23











  • Hmm, I guess I missed your edit and only met the first condition. I'll leave the partial answer as a starting place for anyone who wants to work more on it.

    – Gregor
    Nov 14 '18 at 21:32











  • Thank you @Gregor

    – Tim
    Nov 14 '18 at 21:36











  • Also, I'm confused that 44 is in both V4 and V7. How does that work? Is it okay for 44 to repeat because of that? My answer certainly doesn't take that into account.

    – Gregor
    Nov 14 '18 at 21:36











  • In fact, 44 of the two vectors is not a problem. Of course, the number 44 must not be 2 on the same row. I wrote the data set as an example. I can change 44. In fact, 44 was not supposed to be on 2 vector. However, 3 numbers with v4 and v7 should not have more than 2 members on the same row.

    – Tim
    Nov 14 '18 at 21:48





















  • Thank you for your attention @Gregor but that's not what I want. This code prevents repeated combinations, but does not provide the two conditions I mentioned above. I want vector1,2,3,4,5,6,7 members not to repeat more than 2 times in the same row and 1: 9, 10: 19 ..... to not repeat the numbers more than 3 times. As an example: 1. If the condition is v1 = c (14,15,17,19) I want to have at most 2 of these numbers on each line. As an example: I don't want to have 11,13,15,17 on the same line as the 2nd condition.

    – Tim
    Nov 14 '18 at 21:23











  • Hmm, I guess I missed your edit and only met the first condition. I'll leave the partial answer as a starting place for anyone who wants to work more on it.

    – Gregor
    Nov 14 '18 at 21:32











  • Thank you @Gregor

    – Tim
    Nov 14 '18 at 21:36











  • Also, I'm confused that 44 is in both V4 and V7. How does that work? Is it okay for 44 to repeat because of that? My answer certainly doesn't take that into account.

    – Gregor
    Nov 14 '18 at 21:36











  • In fact, 44 of the two vectors is not a problem. Of course, the number 44 must not be 2 on the same row. I wrote the data set as an example. I can change 44. In fact, 44 was not supposed to be on 2 vector. However, 3 numbers with v4 and v7 should not have more than 2 members on the same row.

    – Tim
    Nov 14 '18 at 21:48



















Thank you for your attention @Gregor but that's not what I want. This code prevents repeated combinations, but does not provide the two conditions I mentioned above. I want vector1,2,3,4,5,6,7 members not to repeat more than 2 times in the same row and 1: 9, 10: 19 ..... to not repeat the numbers more than 3 times. As an example: 1. If the condition is v1 = c (14,15,17,19) I want to have at most 2 of these numbers on each line. As an example: I don't want to have 11,13,15,17 on the same line as the 2nd condition.

– Tim
Nov 14 '18 at 21:23





Thank you for your attention @Gregor but that's not what I want. This code prevents repeated combinations, but does not provide the two conditions I mentioned above. I want vector1,2,3,4,5,6,7 members not to repeat more than 2 times in the same row and 1: 9, 10: 19 ..... to not repeat the numbers more than 3 times. As an example: 1. If the condition is v1 = c (14,15,17,19) I want to have at most 2 of these numbers on each line. As an example: I don't want to have 11,13,15,17 on the same line as the 2nd condition.

– Tim
Nov 14 '18 at 21:23













Hmm, I guess I missed your edit and only met the first condition. I'll leave the partial answer as a starting place for anyone who wants to work more on it.

– Gregor
Nov 14 '18 at 21:32





Hmm, I guess I missed your edit and only met the first condition. I'll leave the partial answer as a starting place for anyone who wants to work more on it.

– Gregor
Nov 14 '18 at 21:32













Thank you @Gregor

– Tim
Nov 14 '18 at 21:36





Thank you @Gregor

– Tim
Nov 14 '18 at 21:36













Also, I'm confused that 44 is in both V4 and V7. How does that work? Is it okay for 44 to repeat because of that? My answer certainly doesn't take that into account.

– Gregor
Nov 14 '18 at 21:36





Also, I'm confused that 44 is in both V4 and V7. How does that work? Is it okay for 44 to repeat because of that? My answer certainly doesn't take that into account.

– Gregor
Nov 14 '18 at 21:36













In fact, 44 of the two vectors is not a problem. Of course, the number 44 must not be 2 on the same row. I wrote the data set as an example. I can change 44. In fact, 44 was not supposed to be on 2 vector. However, 3 numbers with v4 and v7 should not have more than 2 members on the same row.

– Tim
Nov 14 '18 at 21:48







In fact, 44 of the two vectors is not a problem. Of course, the number 44 must not be 2 on the same row. I wrote the data set as an example. I can change 44. In fact, 44 was not supposed to be on 2 vector. However, 3 numbers with v4 and v7 should not have more than 2 members on the same row.

– Tim
Nov 14 '18 at 21:48






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290688%2fconditional-matrix-or-combinations-in-r%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values