Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 805923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:09:49+00:00 2026-05-15T00:09:49+00:00

to become more specific, here is an example: > expand.grid(5, 5, c(1:4,6),c(1:4,6)) Var1 Var2

  • 0

to become more specific, here is an example:

> expand.grid(5, 5, c(1:4,6),c(1:4,6))
   Var1 Var2 Var3 Var4
1     5    5    1    1
2     5    5    2    1
3     5    5    3    1
4     5    5    4    1
5     5    5    6    1
6     5    5    1    2
7     5    5    2    2
8     5    5    3    2
9     5    5    4    2
10    5    5    6    2
11    5    5    1    3
12    5    5    2    3
13    5    5    3    3
14    5    5    4    3
15    5    5    6    3
16    5    5    1    4
17    5    5    2    4
18    5    5    3    4
19    5    5    4    4
20    5    5    6    4
21    5    5    1    6
22    5    5    2    6
23    5    5    3    6
24    5    5    4    6
25    5    5    6    6

This data frame was created from all combinations of the supplied vectors. I would like to create a similar data frame from all permutations of the supplied vectors. Notice that each row must contain exactly 2 fives, yet not necessarily the fist two in line.
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:09:50+00:00Added an answer on May 15, 2026 at 12:09 am

    The code below works. (relies on permutations from gtools)

    comb <- t(as.matrix(expand.grid(5, 5, c(1:4,6),c(1:4,6))))
    perms <- t(permutations(4,4))
    ans <- apply(comb,2,function(x) x[perms])
    ans <- unique(matrix(as.vector(ans), ncol = 4, byrow = TRUE))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do languages become more verbose as they mature? It feels like each new version
As multi-processor and multi-core computers become more and more ubiquitous, is simply firing off
Anticipating the day when multi-touch interfaces become more pervasive, are there libraries in Java
I have let's say 2 (but they'll become more in the future) fully decoupled
I have an ASP.NET website and over time it has become more and more
Title more or less says it all. Specifically, I've become increasingly annoyed that in
I have a JSON character string that I put into a data frame. I
Preface: This has become a quite a long post. While I'm not new to
Okay, so here's an example scenario. There is a student resource resources :students ,
I have several message queues that have specific messages on them. I've created classes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.