

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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?
<p>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 −</p><pre class="result notranslate">"one" "two" "three" "one" "two" "one" three" "two" "three" "one" "two" "three"</pre><h2>Example</h2><p><a class="demo" href="http://tpcg.io/3MCqdlSB" rel="nofollow" target="_blank"> Live Demo</a></p><pre class="prettyprint notranslate">x<-c("India","China","Russia","Canada") unlist(lapply(seq_along(x),combn,x=x,simplify=FALSE),recursive=FALSE)</pre><h2>Output</h2><pre class="result notranslate">[[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"</pre><h2>Example</h2><p><a class="demo" href="http://tpcg.io/G7WTiGDi" rel="nofollow" target="_blank"> Live Demo</a></p><pre class="prettyprint notranslate">y<-c("Winter","Rainy","Summer") unlist(lapply(seq_along(y),combn,x=y,simplify=FALSE),recursive=FALSE)</pre><h2>Output</h2><pre class="result notranslate">[[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"</pre>
- Related Questions & Answers
- 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 vector of lists in R?
- How to create a vector of matrices in R?
- How to create a large vector with repetitive elements of varying size in R?
- How to create combination of multiple vectors in R?
- How to convert a string vector into an integer vector in R?
- How to create a replicated list of a list in R?
- How to create an unordered list without bullets in HTML?
- Extract string vector elements up to a fixed number of characters in R.
- How to remove some last elements of a vector in R?
- How to create vector in R with a sequence of numbers?
Advertisements