2015-03-13 100 views
2


我真的是ggvis的新手,我在網上搜索沒有成功。
我有這樣一個數據集:
ggvis input_select on scale_numeric trans參數

data.example=data.frame("V1"=c(rep("A",times=10),rep("B",times=10)),"V2"=c(runif(10,1,10000),runif(10,100,1000))) 

head(data.example) 
    V1  V2 
    1 A 7261.076 
    2 A 1955.755 
    3 A 3473.473 
    4 A 7593.278 
    5 A 3218.867 
    6 A 4997.951 

tail(data.example) 
V1  V2 
15 B 721.2147 
16 B 185.6676 
17 B 939.3541 
18 B 276.0682 
19 B 910.0322 
20 B 444.2188 

我可以沿y

data.example %>% 
    ggvis(x=~V1,y=~V2,fill=~V1) %>% 
    layer_boxplots() %>% 
    scale_numeric("y",trans="linear") 

做箱線圖與線性度和y中

data.example %>% 
    ggvis(x=~V1,y=~V2,fill=~V1) %>% 
    layer_boxplots() %>% 
    scale_numeric("y",trans="log") 

箱線圖與對數刻度我不能用這樣的代碼做座標變換選擇的動態箱形圖:

select.trans=input_select(choices = c("Linear"="linear","Logarithmic"="log"),selected="linear",label="Scale") 
data.example %>% 
    ggvis(x=~V1,y=~V2,fill=~V1) %>% 
    layer_boxplots() %>% 
    scale_numeric("y",trans=select.trans,expand=0) 

與此錯誤消息:

Error in match(x, table, nomatch = 0L) : 
    'match' requires vectorial arguments 

可能是我忽略了一些重要的東西ggvis?
由於

回答

0

根據the ggvis documentation這只是可能的修改與交互式控件(例如道具),而不是潛在的情節規範(例如尺度)的曲線的數據。

它可以使用閃亮達到你想要做雖然,例如什麼:

library(shiny) 
library(ggvis) 


data.example=data.frame(
    "V1"=c(rep("A",times=10),rep("B",times=10)), 
    "V2"=c(runif(10,1,10000),runif(10,100,1000)) 
) 


shinyApp(
    ui = fluidPage(
     selectInput("trans", label="Scale", 
        choices=list(linear="linear", log="log"), 
        selected="linear"), 
     ggvisOutput("plot") 
    ), 
    server = function(input, output) { 
     reactive({ 
      data.example %>% 
       ggvis(x=~V1,y=~V2,fill=~V1) %>% 
       layer_boxplots() %>% 
       scale_numeric("y", trans=input$trans, expand=0) 
     }) %>% bind_shiny("plot") 
    } 
) 
+0

謝謝!下次我需要仔細閱讀文檔! – 2015-04-09 09:51:00