2013-10-28 16 views
6

Bir rChart'ı parlak bir uygulamada çizmeye çalışıyorum ve bunu Rstudio sunucusu üzerinden çalıştırıyorum. Uygulamayı çalıştırdığımda parlak sayfa hata veriyor: işlev dışı'u uygulamayı dener ve RChart yeni bir tarayıcı penceresinde açılır.rChart parlak uygulamada yeni pencere açar

rChart parlak uygulamada nasıl görünebilir?

server.R

library(shiny) 
require(rCharts) 

names(iris) = gsub("\\.", "", names(iris)) 

shinyServer(function(input, output) { 

output$myChart <- renderChart({ 
h1 <- hPlot(x = "Wr.Hnd", y = "NW.Hnd", data = MASS::survey, 
type = c("line", "bubble", "scatter"), group = "Clap", size = "Age") 
return(h1$show(cdn = TRUE)) 
    }) 
}) 

ui.R

library(shiny) 
require(rCharts) 
shinyUI(pageWithSidebar(

headerPanel("rCharts and shiny"), 

sidebarPanel(), 

mainPanel(
showOutput("myChart") 
) 
)) 

Benim R Oturum bilgileri

R version 3.0.2 (2013-09-25) 
Platform: x86_64-pc-linux-gnu (64-bit) 

other attached packages: 
[1] shiny_0.7.0  plyr_1.8  rCharts_0.3.51 devtools_1.3 ggplot2_0.9.3.1 RMySQL_0.9-3 DBI_0.2-7  

cevap

7

Adını eksik showOutput'da bulunan library. Eğer rCharts ait dev dalını yüklerseniz, o zaman sen kullandığınız arsa hangi tür bağlı ithalat gerekir hangi kütüphane belirtmek zorunda aşağıdaki kodu

library(shiny) 
# devtools::install_github("rCharts", "ramnathv", ref = "dev") 
library(rCharts) 
runApp(list(
    ui = pageWithSidebar(
    headerPanel("rCharts and shiny"), 
    sidebarPanel(

    ), 
    mainPanel(
     showOutput("myChart", "highcharts") 
)), 
    server = function(input, output, session){ 
    output$myChart <- renderChart2({ 
     h1 <- hPlot(x = "Wr.Hnd", y = "NW.Hnd", data = MASS::survey, 
     type = c("line", "bubble", "scatter"), group = "Clap", 
     size = "Age" 
    ) 
     return(h1) 
    }) 
    } 
)) 
8

çalıştırabilirsiniz.

RCharts paketinin açıklamasıyla mevcut tüm kitaplıkların bir list.

İşte rcharts web sitesinde demo kodu ve ben hplot çizmek için değiştirdim.

ui.R

require(rCharts) 
shinyUI(pageWithSidebar(
    headerPanel("rCharts: Interactive Charts from R using highcharts"), 

    sidebarPanel(
    selectInput(inputId = "x", 
       label = "Choose X", 
       choices = c('SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth'), 
       selected = "SepalLength"), 
    selectInput(inputId = "y", 
       label = "Choose Y", 
       choices = c('SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth'), 
       selected = "SepalWidth") 
), 
    mainPanel(
    showOutput("myChart", "highcharts") 
) 
)) 

server.R

require(rCharts) 
shinyServer(function(input, output) { 
    output$myChart <- renderChart({ 
    names(iris) = gsub("\\.", "", names(iris)) 
    # HPLOT 
    p1 <- hPlot(input$x, input$y, data = iris, type = c("line", "bubble", "scatter"), group = "Species", size = 1) 
    # RPLOT 
    #p1 <- rPlot(input$x, input$y, data = iris, color = "Species", facet = "Species", type = 'point') 
    p1$addParams(dom = 'myChart') 
    return(p1) 
    }) 
}) 

enter image description here

İlgili konular