Skip to content

Commit

Permalink
pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
perlatex committed Dec 22, 2021
1 parent 6796399 commit 0b7f7ec
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
8 changes: 7 additions & 1 deletion baseR_objects.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,20 @@ x <- 5
- `option``-`(苹果系统)
:::

```{r, echo=FALSE}

```{r, echo=FALSE, include=FALSE, eval=FALSE}
library(magrittr)
library(ggkeyboard)
ggkeyboard(tkl) %>%
highlight_keys(c("Alt Left", "_-"))
```

```{r, out.width = "100%", echo=FALSE}
knitr::include_graphics("images/keyboard/keyboard_assignment.png")
```


当键入 `x` 然后回车,就打印出 `x` 的值。当然也可以使用命令`print(x)`,结果一样。
```{r}
x
Expand Down
Binary file added images/keyboard/keyboard_assignment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/keyboard/keyboard_insert_chunk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/keyboard/keyboard_pipe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 3 additions & 6 deletions tidyverse_dplyr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,12 @@ c(1:10) %>% sum()

这条语句的意思是`f(x)` 写成 `x %>% f()`,这里向量 `c(1:10)` 通过管道操作符 `%>%` ,传递到函数`sum()`的第一个参数位置,即`sum(c(1:10))`, 这个 `%>%` 管道操作符还是很形象的。在Windows系统中可以通过`Ctrl + Shift + M` 快捷键产生 `%>%`,苹果系统对应的快捷键是`Cmd + Shift + M`

```{r, echo=FALSE}
library(magrittr)
library(ggkeyboard)

ggkeyboard(tkl) %>%
highlight_keys(c("Ctrl Left", "Shift Left", "M"))
```{r, out.width = "100%", echo=FALSE}
knitr::include_graphics("images/keyboard/keyboard_pipe.png")
```


通过下图图示可以看到管道操作符就像生产线上的传送带一样,将数据运入函数中。
```{r out.width = '45%', echo = FALSE}
knitr::include_graphics("images/pipe1.png")
```
Expand Down
4 changes: 3 additions & 1 deletion tidyverse_rmarkdown.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ knitr::include_graphics("images/rstudio-markdown.png")

在 Rmd 文档中写 R 代码,需要插入代码块(Code chunks),具体以 ` ```{r} ` 开始,以 ` ``` `结尾。可以用快捷方式**`Ctrl + Alt + I`** (**OS X: `Cmd + Option + I`**)创建代码块。


```{r, out.width = "100%", echo=FALSE}
knitr::include_graphics("images/keyboard/keyboard_insert_chunk.png")
```


点击knit(下图中红色地方),选择想要输出的文档格式即可。下图是Rmd文档与渲染效果效果,
Expand Down

0 comments on commit 0b7f7ec

Please sign in to comment.