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 8476089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:04:59+00:00 2026-06-10T18:04:59+00:00

In a data frame, I have one column containing character strings. Let’s say it

  • 0

In a data frame, I have one column containing character strings. Let’s say it looks like this:

x <- unique(df[,1])
x
"A" "A" "B" "B" "B" "C"

I’d like to get all possible combinations of the unique character strings as sets of 2 without caring about their order, so A, B is the same as B, A, and I don’t want to get same values as combination like A, A. So far, I got until this point:

comb <- expand.grid(x, x)
comb <- comb[which(comb[,1] != comb[,2]),]

But this still leaves the problem of having rows with the same combination of strings in a different order. How do I get rid of this?

  • 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-06-10T18:05:00+00:00Added an answer on June 10, 2026 at 6:05 pm

    There’s the combn function in the utils package:

    t(combn(LETTERS[1:3],2))
    #      [,1] [,2]
    # [1,] "A"  "B" 
    # [2,] "A"  "C" 
    # [3,] "B"  "C"
    

    I’m a little confused as to why your x has duplicated values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's have a dataframe with long strings in one column: df<-data.frame(short=rnorm(10,0,1),long=replicate(10,paste(rep(sample(letters),runif(1,5,8)),collapse=))) How could I
Suppose I have a dataframe like this one: df <- data.frame (id = c(a,
I have a dataframe with numeric entries like this one test <- data.frame(x =
I have a data.frame with one column, like so: >d = data.frame(animal=c(horse,dog,cat)) then I
I have a data frame which looks like this: inten new.probes 12.28280 AFFX-r2-P1-cre-5_at 12.35039
I have a data frame where one particular column has a set of specific
I have a data frame containing 10k rows, for a given column X I
I am attempting to filter data frames that have only one column. This results
I have a data set which looks something like data<-c(0,1,2,3,4,2,3,1,4,3,2,4,0,1,2,0,2,1,2,0,4) frame<-as.data.frame(data) I now want
I have a large data frame that looks similar to this: df <- data.frame(dive

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.