[R] knitr without R studio

Yihui Xie xie at yihui.name
Wed Jun 19 20:07:52 CEST 2013


knitr is not tied to RStudio, and I believe this StackOverflow post
can answer your question: http://stackoverflow.com/q/10646665/559676

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle


On Wed, Jun 19, 2013 at 4:42 AM, Ista Zahn <istazahn at gmail.com> wrote:
> Hi Alex,
>
> Have you read the ?knit or ?knit2html documentation? I don't believe
> there is a kit2HTML function (notice the uppercase), and the input
> should be the path to a file. Please do read the documentation.
>
> Best,
> Ista
>
> On Wed, Jun 19, 2013 at 3:53 AM, AlexPiche
> <alexandre.piche at mail.mcgill.ca> wrote:
>> Hello folks,
>>
>> I`m using knitr on R studio, which make it easy to use, but a coworker of
>> mine would like to run it on "simple" R. So I was wondering if you know what
>> is the equivalent of  the button "knit HTML" in RStudio in R. I tried
>>
>>
>> knit2HTML(
>>
>> <html>
>> <head>
>>   <title></title>
>> </head>
>> <body style="background-color:white">
>>
>>
>>
>>
>>   <p style="font-size:16px; text-align:center">
>> Graph 1 <#location1>      Graph 2 <#location2>
>>   </p>
>>
>> ```{r table1, comment=NA, results='asis'}
>> library(xtable)
>> data(iris)
>> print(xtable(head(iris, 10)), type = "html", include.rownames = T)
>> ```
>>
>>
>>
>> ```{r, include=FALSE}
>>
>>
>> opts_knit$set(progress = TRUE, verbose = TRUE)
>> opts_chunk$set(fig.width=20, fig.height=12)
>> knit_hooks$set(fig.bg = function(before, options, envir) {
>>   if (before) par(bg = options$fig.bg)
>> })
>>
>> ```
>>
>>
>>
>>
>>
>>
>> ```{r graphs,fig.keep=’last’}
>> for (x in 1:10) plot(rnorm(100), col = x)
>> ```
>>
>>
>>
>>
>> ```{r graph1}
>>
>> plot(rnorm(500), type="lines", main="Graph1")
>> ```
>>   Top of the Page <#top>
>>
>>
>>
>>
>>
>> ```{r graph2}
>>
>>
>> plot(rpois(500,3), type="lines", main="Graph2")
>>
>> ```
>>
>> Top of the Page <#top>
>>
>>
>>
>>
>>
>> </body>
>> </html>
>> )
>>
>>
>> But R keep sending me error message, any clue?
>>
>> Regards,
>>
>> Alex



More information about the R-help mailing list