首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >rmarkdown 入门

rmarkdown 入门

原创
作者头像
用户11593460
发布于 2025-04-02 11:19:37
发布于 2025-04-02 11:19:37
4390
举报

没用和警示的信息不要展示 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
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
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站)

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

目录
  • 没用和警示的信息不要展示 message = F,warning = F
  • R markdown 插入代码块快捷键 Ctrl+Alt+i
  • 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
    • 全局设置常见选项
  • 1 6
  • 1 "hello world!"
    • 输出图片 plot()
    • 输出表格 head()
  • 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
    • 输出为md的格式,代码:Knitr::knit("")
    • 引用代码 >
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档