如何在shiny / ggplot2 app上的一个selectInput中使用多个data.frame对象

时间:2016-05-25 21:00:12

标签: r ggplot2 shiny

我正在使用R 3.2.3通过RStudio版本0.99.491,在Windows 10 64bit ...我正在创建一个ggplot2闪亮的应用程序,它显示一个气泡图。除了关于输入的事实外,我不理解我收到的错误消息:

library(shiny)
library(leaflet)

vars = c("april" = "April","may" = "May","june" = "June","july" = "July")

shinyUI(pageWithSidebar(    
sidebarPanel(
  selectInput("month", "Month", vars, selected = "april")),
mainPanel(plotOutput("plot")

)))

这是我正在使用的$routeParams。这是代码

UI

library(shiny) 
library(leaflet)



melt_april <- melt(april)
names(april) = c('departure', 'stop', 'frequency')
melt_may <- melt(may)
names(may) = c('departure', 'stop', 'frequency')
melt_june <- melt(june)
names(june) = c('departure', 'stop', 'frequency')
melt_july <- melt(july)
names(july) = c('departure', 'stop', 'frequency')

 monthBy <- input$month




shinyServer( function(input, output){
observe({
  output$plot <- renderPlot({


     p <- ggplot(monthBy, aes(x = departure, y =stop, size = frequency, color = frequency)) + 
      geom_point()+
      scale_colour_gradient(low="white",high="orange")+

    print(p)

  )
})

SEVER

foreach ($lines as $line) {
    #Increment the line number
    $lineNum++;

    #Save the current indentation for later use
    $currentIndentation = strspn($line, " ");

    #Go though list of unclosed tags and recursivley close all that need to be closed
    for($i=count($unclosed_tags)-1; $i>= 0; $i--){
        $tag = $unclosed_tags[$i];
        #Assign a variable to the tag indentation
        $tagIndentation = $tag[1];

        echo $tag[0] . "$tagIndentation:$currentIndentation=" . !($tagIndentation < $currentIndentation) . "<br>";

        #Check if the current indentation is not smaller than the tag
        if ($tagIndentation >= $currentIndentation) {
            #Close the tag
            $output .= "</" . $tag[0] . ">";
            #Remove the tag from unclosed list cince we just closed it
            unset($unclosed_tags[$i]);
        } else {
            break;
        }
    }

    #Get the current element (== the first string in a string)
    $currentElement = preg_replace('/(\s*)([^\s]*)(.*)/', '$2', $line);

    #Output as open tag
    $output .= "<" . $currentElement . ">" . trim(str_replace_first($currentElement, "", $line));
    #Add to list of unclosed tags
    $unclosed_tags[] = array($currentElement, $currentIndentation);
}

})

1 个答案:

答案 0 :(得分:0)

好的,我想你可能需要

 monthBy <- input$month

shinyServer函数内。