Learn R Programming

CoopGame (version 0.2.2)

getPlayersFromBMRow: Extract players from bit matrix row

Description

getPlayersFromBMRow determines players involved in a coalition from the row of a bit matrix

Usage

getPlayersFromBMRow(bmRow)

Arguments

bmRow

represents the bit matrix row

Value

playerVector contains involved players (e.g. c(1,3), see example below for bitIndex=5 and n=3)

Examples

Run this code
# NOT RUN {
library(CoopGame)
bm=createBitMatrix(n=3,A=c(0,0,0,1,1,1,2))
getPlayersFromBMRow(bmRow=bm[4,])

# }
# NOT RUN {
library(CoopGame)
bm=createBitMatrix(n=3,A=c(1:7))
#Corresponding bit matrix:
#           cVal
#[1,] 1 0 0    1
#[2,] 0 1 0    2
#[3,] 0 0 1    3
#[4,] 1 1 0    4
#[5,] 1 0 1    5 <=Specified bit index
#[6,] 0 1 1    6
#[7,] 1 1 1    7

#Determine players from bit matrix row by index 5
players=getPlayersFromBMRow(bmRow=bm[5,])
#Result:
players 
#[1] 1 3
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab