Hello Winston, Joe.
On Monday, March 25, 2013 5:55:27 PM UTC+1, Joe Cheng [RStudio] wrote:
You also need to add another variable scope (local()) so that in_name is not shared between all the different renderText calls (this is an R thing, not a Shiny thing):
Thanks for the great suggestion: double-bracket indexing and local do the job.
output_names <- c(
"profileA1",
"profileB1",
"profileA2",
"profileB2",
"profileA3",
"profileB3",
"profileA4",
"profileB4"
)
reactive_names <- c(
"game1PlayerAProfile",
"game1PlayerBProfile",
"game2PlayerAProfile",
"game2PlayerBProfile",
"game3PlayerAProfile",
"game3PlayerBProfile",
"game4PlayerAProfile",
"game4PlayerBProfile"
)
for (out_name in output_names) {
local({
my_out_name <- out_name
info_names <- c("Card", "Player", "Rating")
for (info_name in info_names) {
local({
my_info_name <- info_name
complete_out_name <- paste(my_out_name, my_info_name, sep = "")
output[[complete_out_name]] <<- renderText({
my_profile <- get(reactive_names[which(output_names == my_out_name)])()
my_profile[[tolower(my_info_name)]]
})
})
}
})
}