2016-11-29 25 views
1

dygraphsパッケージを使用してプロットを作成する光沢のあるアプリがあります。プロットの軸ラベルに上付き文字と特殊文字を使用する必要があります。私はexpression()bquote()を試しましたが、[オブジェクトオブジェクト]としてラベルが印刷されるので、dygraphsはこれらの関数を評価できるようには見えません。dygraphs軸ラベルに上付き文字と特殊文字を入れる方法

ここには最小の例があります。私はyラベルの87と86を上付き文字にし、xラベルにmu文字を使用する必要があります。

library(shiny) 
library(dygraphs) 

ui <- fluidPage(dygraphOutput("dygraph")) 

server <- shinyServer(function(input, output, session) { 

    sampleplot <- function(){ 
    norm <- rnorm(1000,mean=50,sd=7) 
    dist <- seq(1,1000,by=1) 
    dat <- as.data.frame(cbind(dist,norm)) 
    names(dat) <- c("Distance","Normal") 
    dygraph(dat, ylab="87Sr/86Sr",xlab="Distance (um)") %>% 
     dySeries("Normal",drawPoints = TRUE, pointSize = 2, strokeWidth = 0.0)} 

    output$dygraph <- renderDygraph({sampleplot()}) 


    } 
) 


shinyApp(ui=ui,server=server) 

答えて

1

私はJSのdygraphsオプションWebページを読んで、軸ラベルにはテキストだけでなくHTMLも使用できることが分かりました。上付き文字http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_supと特殊文字http://www.htmlhelp.com/reference/html40/entities/symbols.htmlをHTMLで入力する方法を見て、うまくいきました。

library(shiny) 
library(dygraphs) 

ui <- fluidPage(dygraphOutput("dygraph")) 

server <- shinyServer(function(input, output, session) { 

    sampleplot <- function(){ 
    norm <- rnorm(1000,mean=50,sd=7) 
    dist <- seq(1,1000,by=1) 
    dat <- as.data.frame(cbind(dist,norm)) 
    names(dat) <- c("Distance","Normal") 
    dygraph(dat, ylab="<sup>87</sup>Sr/<sup>86</sup>Sr",xlab="Distance (&mu;m)") %>% 
     dySeries("Normal",drawPoints = TRUE, pointSize = 2, strokeWidth = 0.0)} 

    output$dygraph <- renderDygraph({sampleplot()}) 


    } 
) 


shinyApp(ui=ui,server=server) 
関連する問題