Reputation: 43
I am trying to find out the R code which will give me the output of the statistical analysis(i.e. Regression, DOE, Gage RR) in pdf or html format by using R ( Not by using R-studio). I want to generate report of my statistical analysis. Is there any R code which we can run in to the R to make pdf or html file ??. I know it for graphs only,
pdf("output.pdf")
x=rnorm(100,40,3)
y=rnorm(100,100,5)
fit=lm(y~x)
summary(fit)
plot(y)
dev.off()
This code gives me graph in pdf but I want all the summary of fit (ANOVA) and all information that R generates. Thanks
Upvotes: 3
Views: 27143
Reputation: 893
Yes, RMarkdown/knitr is the way to go.
See here for the documentation for creating a pdf document.
Your Rmd file might look something like the following:
---
title: "Report"
author: "XXX"
date: "January 7, 2017"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Output
```{r}
x <- rnorm(100, 40, 3)
x
y <- rnorm(100, 100, 5)
y
fit <- lm(y ~ x)
summary(fit)
```
## Plot
```{r plot, echo=FALSE}
plot(y)
```
For an html document, simply change to output: html_document
.
Render the pdf or html document with rmarkdown::render('filepath/yourfile.Rmd')
Upvotes: 3