The problem I have is that I am not able to automatically generate a GUI in Shiny. The idea is to see how many files there are and generate a set of Image + button for each file. I believe the solution to this problem is the solution to ANY GUI generation in R.
I am able to do this statically, writing the code for each button and image, but it doesn't work to put it in a for loop, or to render the image in the server.R and pass it as HTML to the ui.R. I will explain below.
The code I want to generate is:
actionButton("sug1",icon=imageOutput("sug1",width="100px",height="100px"),label="First")
Which gives me a 100x100 clickable image.
I have tried the following:
1) Surrounding it with a for loop inside of ui.R and making the ID("sug1") and the label a variable where the last number increments each loop.
2) Accumulating the result and using the HTML() function in server.R to later output it in ui.R
output$generateImages <- renderUI({
(...)
for(...){
(...)
w <- paste(w, actionButton(paste("oc",which(dir==folders)),label=dir))
}
HTML(w)
})
and then in ui.R in the place I want it to appear:
htmlOutput("generateImages")
3) I guessed that using HTMLoutput or UIOutput should help, but given that the HTML output my code generates(as seen in righ tlick/view page source) is:
<button id="sug1" type="button" class="btn action-button">
<div id="sug1" class="shiny-image-output" style="width: 100px ; height: 100px"></div>
First
</button>
I was not able to figure out how to generate this as I knew not how and where to insert a reference to an image.
Would appreciate help.
tagList, and possiblerenderUI. If you take a minute to familiarize yourself with theapplyfamily of functions, I expect you could probably get it working withtagList(lapply( <your code here>)). - Jeff Allen