r
  • knitr
  • r-markdown
  • plotly
  • ggplotly
  • 2017-09-22 2 views 1 likes 
    1

    プロットされたプロットを含むRmarkdown文書があり、htmlファイルを生成したいと考えています。私はRstudioでをHTMLにニットをクリックしたときに動作しますが、私は、コマンドラインで次のように実行していないとき:この後Rmarkdownレポートでプロット的なインタラクティブプロットを生成できません

    Rscript -e "require(knitr)" -e "require(markdown)" -e "knit('Untitled.Rmd', out='report.md')" -e "markdownToHTML('report.md', 'report.html')" 
    

    、私はplotlyで生成されたプロットが含まれているreport.htmlをファイルを持っていますしかし、インタラクティブではありません。 コマンドラインでインタラクティブにする方法を知っている人はいますか?

    おかげ

    これはところで、コードです:

    --- 
    title: "Untitled" 
    output: html_document 
    --- 
    
    ```{r setup, include=FALSE} 
    knitr::opts_chunk$set(echo = TRUE) 
    ``` 
    
    ## R Markdown 
    
    This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>. 
    
    When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: 
    
    ```{r cars} 
    summary(cars) 
    ``` 
    
    ## Including Plots 
    
    You can also embed plots, for example: 
    
    ```{r pressure_ggplot, echo=FALSE} 
    library(ggplot2) 
    library(plotly) 
    ggplot(pressure,aes(temperature,pressure))+geom_point(size=10,color='red') 
    ``` 
    
    Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot. 
    ```{r pressure_plotly, echo=FALSE} 
    
    g<-ggplot(pressure,aes(temperature,pressure))+geom_point(size=10,color='red') 
    ggplotly(g) 
    ``` 
    ```{r} 
    sessionInfo() 
    ``` 
    
    +0

    [このリンク](https://plot.ly/r/knitr/#embedding-plotly-graphs-in-rmd-files)をチェックすると、 'htmltools :: tags $ ....'プロットを埋め込むために – parth

    +0

    いいえ、実際はそうではありません。私はRstudioの中から編み出したときにプロットされたプロットを取得しますが、コマンドラインからは行いません。私は自分自身を少し不明確に説明したかもしれません。 –

    答えて

    0

    試してみてください。

    Rscript -e "library(knitr); library(rmarkdown); rmarkdown::render('untitled.Rmd', output_file='report.html')"

    推論:ニットの出力をマークダウンするデフォルトのようだ、と値下げはHTMLを含めることはできません。したがって、変換時に欠落したファイルが残ってしまいます(echo=FALSEをコードブロックの開口部から削除すると、これらのエラーが表示されることがあります)。

    rmarkdown::render([...])は、上記の問題を避けて出力を明瞭にレンダリングします。形式を使用する場合は、output_format引数を使用してください。

    +0

    それは動作します!ありがとう –

    関連する問題