-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02-Rmarkdown.Rmd
More file actions
65 lines (46 loc) · 1.1 KB
/
02-Rmarkdown.Rmd
File metadata and controls
65 lines (46 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: "rmarkdowm_1"
author: "xlliang"
date: "2020/11/2"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# 数据输入x
```{r}
set.seed(1)
x <- round(rnorm(10),2)
print(x)
```
#图形输出
```{r, echo=FALSE}
plot(x)
```
# 富文本表格输出
```{r}
knitr::kable(as.data.frame(x))
```
#保存
```{r}
rmarkdown::render("02-Rmarkdown.Rmd",output_format = "html_document",encoding = "UTF-8")
rmarkdown::render("02-Rmarkdown.Rmd",output_format = "word_document",encoding = "UTF-8")
```
# 新增一个代码段 ctrl+alt+i
## knitr包提供了一个 kable() 函数可以用来把数据框或矩阵转化成有格式的表格, 支持HTML、docx、LaTeX等格式
```{r}
x <- 1:10; y <- x^2; lmr <- lm(y~x)
co <- summary(lmr)$coefficient
print(co)
knitr::kable(co) #kable()函数的digits=选项可以控制小数点后数字位数,caption=选项可以指定表的标题内容。
```
## xtable
```{r}
print(xtable::xtable(lmr),type = "html")
```
## pander
```{r}
pabder:pander(lmr)
```
```{r}
```