I have been trying to make a visual of a game theory payoff matrix in R, but can't generate a visual. I found an attempt to answering this question in another payoff matrix post, but the code is not producing the visual. I would appreciate any suggestions.
Here is the code from the other post:
###########################################################################
############# Game Theory Payoff Matrix Visual ############################
###########################################################################
# Packages
library(rmarkdown)
library(knitr)
# Define Variables
T=2
R=1
P=0
S=-1
# Assign Pairs
pair <- function(x,y) sprintf("(%d,%d)", x,y)
all_pairs <- c(pair(T,S), pair(P,P), pair(R,R), pair(S,T))
payoff.mat <- matrix(all_pairs, nrow=2)
dimnames(payoff.mat) <- c(rep(list(c("Gift","NoGift")), 2))
results = "asis"
# Plot
kable(payoff.mat)
print(all_pairs, type="html")
While I have my own data, the intended template of the other post applies to my publication needs.
Also, is there a way to make a variety of plain to fancy payoff matrix visuals in R?
Again, I would appreciate any considerations.