Skip to content
Prev 278083 / 398506 Next

Sub sets

On Nov 21, 2011, at 11:42 AM, R. Michael Weylandt wrote:

            
Michael's function is very nice (although the n= parameter seems  
superfluous since any value other than the length of 'items' will get  
discarded). However, your use case was not specified so I cannot know  
if you wanted set notation or matrix class objects. Here's another  
option in case you wanted set notation:

 > require(sets)
Loading required package: sets
 > as.set(c(2,3,4,5))
{2, 3, 4, 5}
 > X <- as.set(c(2,3,4,5))
 > set_power(X)
{{}, {2}, {3}, {4}, {5}, {2, 3}, {2, 4}, {2, 5}, {3, 4}, {3, 5}, {4, 5},
  {2, 3, 4}, {2, 3, 5}, {2, 4, 5}, {3, 4, 5}, {2, 3, 4, 5}}

The set package offers an extensive list of set oriented functions.