Displaying 2 results from an estimated 2 matches for "bag2".
Did you mean:
bag
2009 Jan 27
2
working with tables -- was Re: Mode (statistics) in R?
...eq(1,10),50,replace=TRUE)->bag
Rgames> bag
[1] 2 8 8 10 7 3 2 9 8 3 8 9 6 6 10 10 7 1
[19] 9 5 4 3 3 5 10 3 6 3 2 8 4 2 1 10 6 2
[37] 6 6 9 8 6 8 8 4 3 6 3 9 5 1
Rgames> names(which.max(table(bag)))
[1] "3"
I can then do
Rgames> bag2<-bag[bag!=3]
and repeat the which.max stuff.
I came up with the following command to find the actual magnitude of the
mode:
Rgames> table(bag)->tbag
Rgames> tbag
bag
1 2 3 4 5 6 7 8 9 10
3 5 8 3 3 8 2 8 5 5
Rgames> tbag[dimnames(tbag)$bag=="3"]->...
2010 Jan 14
2
Fixed size permutations
I'm using functions to return a matrix of all permutations of a
specified size from a larger list for predictor selection.
For each predictor size I use a seperate function like this:
bag2 <- function(n) {
rl <- c()
for (i1 in seq(n)) {
for (i2 in seq(n)) {
if (length(unique(c(i1,i2)))==1) {next}
rl <- cbind(rl,matrix(c(i1,i2)))
}
}
rl
}
bag3 <- function(n) {
rl <- c()
for (i1 in seq(n)) {
for (i2...