- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a list of an unordered combination of elements in a string vector in R?
An unordered combination of elements means that the combination of the values in a way that does not make any particular arrangement. For example, if we have three values one, two, and three then they can be arranged in the following way which is unordered −
"one" "two" "three" "one" "two" "one" three" "two" "three" "one" "two" "three"
Example
x<-c("India","China","Russia","Canada") unlist(lapply(seq_along(x),combn,x=x,simplify=FALSE),recursive=FALSE)
Output
[[1]] [1] "India" [[2]] [1] "China" [[3]] [1] "Russia" [[4]] [1] "Canada" [[5]] [1] "India" "China" [[6]] [1] "India" "Russia" [[7]] [1] "India" "Canada" [[8]] [1] "China" "Russia" [[9]] [1] "China" "Canada" [[10]] [1] "Russia" "Canada" [[11]] [1] "India" "China" "Russia" [[12]] [1] "India" "China" "Canada" [[13]] [1] "India" "Russia" "Canada" [[14]] [1] "China" "Russia" "Canada" [[15]] [1] "India" "China" "Russia" "Canada"
Example
y<-c("Winter","Rainy","Summer") unlist(lapply(seq_along(y),combn,x=y,simplify=FALSE),recursive=FALSE)
Output
[[1]] [1] "Winter" [[2]] [1] "Rainy" [[3]] [1] "Summer" [[4]] [1] "Winter" "Rainy" [[5]] [1] "Winter" "Summer" [[6]] [1] "Rainy" "Summer" [[7]] [1] "Winter" "Rainy" "Summer"
- Related Articles
- How to create unordered triplets of a vector elements in R?
- How to create a combination of pairs from a vector in R?
- How to create frequency table of a string vector in R?
- How to create a matrix using vector of string values in R?
- How to find the intersection of elements in a string vector in R?
- How to create a large vector with repetitive elements of varying size in R?
- How to create a vector of lists in R?
- How to create a vector of matrices in R?
- How to create an unordered list without bullets in HTML?
- How to convert a string vector into an integer vector in R?
- How to create an upper triangular matrix using vector elements in R?
- How to create a vector with names of its elements in one line code in R?
- Extract string vector elements up to a fixed number of characters in R.
- How to create an unordered list with disc bullets in HTML?
- How to create an unordered list with circle bullets in HTML?

Advertisements