1

This is a basic practice question in http://shiny.rstudio.com/tutorial/written-tutorial/lesson2/ and the answer also seems to match upto a certain point but when the app is run the photo is not shown even if in the working directory. Could somebody please help.

library(shiny)

# Define UI
ui <- fluidPage(
titlePanel(strong("My shiny app"), windowTitle = "My first"),

sidebarLayout(sidebarPanel(

   h1(strong("Installation")),
   p("Shiny is available on CRAN, so you can install it in the usual way from your R console:"),
   p(code('install.package("shiny")')),
   br(),
   br(),
   br(),
   br(),
   img(src = "rstudio.png", height = 70, width = 200)
                                 )
   mainPanel("main panel"))
    )

# Define server logic
server <- function(input, output) {


    }

# Run the application 
shinyApp(ui = ui, server = server)

The answer shown on the answer can be seen with the help of reveal answer below the image. Image path:- http://shiny.rstudio.com/tutorial/written-tutorial/lesson2/images/my-shiny-app.png

I am still learning so the whole code has not bee written and i have no separate www/ directory as this is just for learning process. Not creating a logo or something as in the other similar question. This is just upto the image addition point.

rahul yadav
  • 432
  • 3
  • 20

1 Answers1

1

You have error in code.
Add full path to the file. Sometimes Rstudio-viewer didn't show images. But you always can open app into browser.

ui <- fluidPage(
  titlePanel(strong("My shiny app"), windowTitle = "My first"),

  sidebarLayout(sidebarPanel(

    h1(strong("Installation")),
    p("Shiny is available on CRAN, so you can install it in the usual way from your R console:"),
    p(code('install.package("shiny")')),
    br(),
    br(),
    br(),
    br(),
    img(src = "http://shiny.rstudio.com/tutorial/written-tutorial/lesson2/images/my-shiny-app.png", height = 70, width = 200)
  ),
  mainPanel("main panel"))
)
jyjek
  • 2,627
  • 11
  • 23
  • But what if i become a server. I cant then link my image to another site as it would then increase traffic and finally if they remove i would have no other source. Is there no other way – rahul yadav Jun 14 '18 at 11:57
  • The problem was that i added the photo in my r working directory but it had to be added in the shiny directory – rahul yadav Jun 15 '18 at 05:56