Below is my code. I am able to produce the ecdf plots in R studio but not when i put it all together in a shiny app like I have below:
Server.R
library(shiny)
library(ggplot2)
shinyServer(function(input, output) {
datasetInput <- reactive({
mydf = data.frame(
a = rnorm(100, 0, 1),
b = rnorm(100, 2, 1),
c = rnorm(100, -2, 0.5)
)
mydf_m = melt(mydf)
mydf_m <- ddply(mydf_m,.(variable),transform, ecd = ecdf(value)(value))
})
output$myplot <- renderGvis({
p<-(ggplot(mydf_m,aes(x = value, y = ecd)) +
geom_line(aes(group = variable,colour = variable)))
print(p)
})
})
ui.R
library(shiny)
library(ggplot2)
shinyUI(fluidPage(
titlePanel("title panel"),
sidebarLayout(
sidebarPanel( "sidebar panel"),
mainPanel(
tabsetPanel(
tabPanel("Tab 1", h4("Head 1"),plotOutput("myplot"))
)
)
)
))
What am I doing wrong?
You have a reactive data set in
datasetInput
but you aren't using it in your plotting function. In yourggplot
call just replacemydf_m
withdatasetInput()
. I also replacedrenderGvis
withrenderPlot
and return the data from the reactivedatasetInput
. The server is then