2013-10-28 6 views
6

반짝 이는 응용 프로그램에서 rChart를 플롯하고 Rstudio 서버를 통해이를 실행하려고합니다. 앱을 실행하면 반짝이는 페이지에 오류가 발생합니다 : 이 아닌 기능을 적용하려고 시도하면 RChart가 새 브라우저 창에서 열립니다.rChart가 반짝이는 응용 프로그램에서 새 창을 엽니 다.

빛나는 응용 프로그램에서 rChart를 어떻게 나타낼 수 있습니까?

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") 
) 
)) 

내 R 세션 정보

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  

답변

7

당신은 이름을 누락 libraryshowOutput 당신이 rChartsdev 지점을 설치하는 경우에, 당신은 당신이 사용하는 플롯의 종류에 따라 수입해야하는 라이브러리를 지정해야 다음 코드

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

을 실행할 수 있습니다.

여기 rCharts 패키지의 설명에서 사용 가능한 모든 라이브러리 중 list입니다.

datatables 
dimple 
highcharts 
leaflet 
morris 
nvd3 
polycharts 
rickshaw 
vega 
xcharts 

다음은 rcharts 웹 사이트의 데모 코드이며 hplot을 플롯하기 위해 수정되었습니다.

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

관련 문제