Quantcast
Viewing all articles
Browse latest Browse all 206305

Need help in writing such a code in R without using any packages

Write a function that takes a number of inputs (p) and size of a subset (k) and outputs a matrix where each row is a vector of TRUE/FALSE values (k TRUE entries, p - k FALSE entries) and together the rows define all possible subsets of size k.

For example, if p = 3 and k = 2 the matrix could be

TRUE TRUE FALSE
TRUE FALSE TRUE
FALSE TRUE TRUE

Such a function would be useful for automating the best subset selection algorithm.


Viewing all articles
Browse latest Browse all 206305

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>