admin管理员组

文章数量:1442514

rmarkdown 入门

没用和警示的信息不要展示 message = F,warning = F

R markdown 插入代码块快捷键 Ctrl+Alt+i

r

head(iris)

txt

Sepal.Length Sepal.Width Petal.Length Petal.Width Species

1 5.1 3.5 1.4 0.2 setosa

2 4.9 3.0 1.4 0.2 setosa

3 4.7 3.2 1.3 0.2 setosa

4 4.6 3.1 1.5 0.2 setosa

5 5.0 3.6 1.4 0.2 setosa

6 5.4 3.9 1.7 0.4 setosa

txt

r

plot(iris$Sepal.Length)

text

plot of chunk unnamed-chunk-2

全局设置常见选项

  • 代码仅显示不运行 eval=FALSE

r

print("hello world!")

txt

  • 代码仅运行不显示 include=FALSE
  • 显示代码 echo=TRUE

r

print(a)

txt

1 6

txt

  • 代码块和输出结果一起显示 collapse=TRUE

r

print("hello world!")

1 "hello world!"

txt

  • 去掉## comment=""

r

print("hello world!")

1 "hello world!"

txt

  • 显示> prompt=TRUE

r

print("hello world!") 1 "hello world!"

txt

输出图片 plot()

r

plot(1:5, 1:5)

txt

plot of chunk unnamed-chunk-9

输出表格 head()

r

head(mtcars,5)

txt

txt

mpg cyl disp hp drat wt qsec vs am gear carb

Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4

Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4

Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1

Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1

Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2

txt

输出为md的格式,代码:Knitr::knit("")

引用代码 >

引用自生物技能树,阅读使我快乐2016(b站)

本文标签: rmarkdown 入门