Skip to content

Commit

Permalink
bs4_book
Browse files Browse the repository at this point in the history
  • Loading branch information
perlatex committed Sep 8, 2021
1 parent 7c9ef31 commit 8ec824f
Show file tree
Hide file tree
Showing 74 changed files with 4,223 additions and 1,306 deletions.
28 changes: 16 additions & 12 deletions _bookdown.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
book_filename: R4DS
clean: [packages.bib, bookdown.bbl]
delete_merged_file: true
language:
label:
fig: ""
Expand All @@ -15,12 +16,17 @@ rmd_files: [

# 基础篇
"intro_ds.Rmd",
"intro_R.Rmd",
"subsetting.Rmd",
"install.Rmd",
"objects.Rmd",

"vector.Rmd",
"data-structure.Rmd",
"operators.Rmd",

"functions.Rmd",
"subsetting.Rmd",

# tidyverse篇
# tidyverse篇
"rmarkdown.Rmd",
"readr.Rmd",
"dplyr.Rmd",
Expand Down Expand Up @@ -49,7 +55,7 @@ rmd_files: [
"dot.Rmd",
"tidyeval.Rmd",

# 建模篇
# 建模篇
"sampling.Rmd",
"lm.Rmd",
"broom.Rmd",
Expand All @@ -63,7 +69,7 @@ rmd_files: [
"tidymodels.Rmd",
"bayesian_models.Rmd",

# 应用篇
# 应用篇
"eda_nobel.Rmd",
"eda_olympics.Rmd",
"eda_covid2019.Rmd",
Expand All @@ -73,19 +79,17 @@ rmd_files: [
"eda_penguins.Rmd",
"eda_career_decision.Rmd",
"eda_ames_houseprice.Rmd",
"eda_vaccine_effectiveness.Rmd",
"rvest.Rmd",
# "rvest.Rmd", #
"tidygraph.Rmd",
"tidytext.Rmd",
"slider.Rmd",
"stars.Rmd",
"rowwise.Rmd",
"ggplot2_academic.Rmd",

"ggplot2_gganimate.Rmd",
# "ggplot2_academic.Rmd", #
# "ggplot2_gganimate.Rmd", #
"lazyman.Rmd",
# "pandas.Rmd",
"practice.Rmd",
# "pandas.Rmd", #
# "practice.Rmd", #

"Appendix.Rmd",
"references.Rmd"
Expand Down
37 changes: 6 additions & 31 deletions _output.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
bookdown::gitbook:
css: [css/psyteachr.css, css/style.css]
config:
toc:
collapse: none
before: |
<li><a href="./">数据科学中的R语言</a></li>
after: |
<li><a href="https://bookdown.org" target="blank">本书由 bookdown 强力驱动</a></li>
download: [pdf, epub]
edit: https://github.com/yihui/bookdown-chinese/edit/master/%s
sharing:
github: yes
facebook: no
bookdown::pdf_book:
includes:
in_header: latex/preamble.tex
before_body: latex/before_body.tex
after_body: latex/after_body.tex
keep_tex: yes
dev: "cairo_pdf"
latex_engine: xelatex
citation_package: natbib
template: latex/template.tex
pandoc_args: "--top-level-division=chapter"
toc_depth: 3
toc_unnumbered: no
toc_appendix: yes
quote_footer: ["\\begin{flushright}", "\\end{flushright}"]
bookdown::epub_book:
stylesheet: css/style.css
bookdown::bs4_book:
theme:
primary: "#035004"
split_by: chapter
split_bib: no

6 changes: 4 additions & 2 deletions adv_dplyr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,14 @@ iris %>%
上面这个代码,数据框分割成list, 处理完后再合并成数据框,难道不觉得折腾么? 为什么直接点?
tidyverse不会让我们失望的,先看看`group_map()`
```{r adv-dplyr-34}
## The result of .f should be a data frame(.f 必须返回数据框)
## `group_map()` return a list of tibble(返回元素均为df的一个列表list(df1,df2,df3))
iris %>%
dplyr::group_by(Species) %>%
dplyr::group_map(~ broom::tidy(lm(Petal.Length ~ Sepal.Length, data = .x)))
```

- `group_map()`要求 The result of .f should be a data frame(.f 必须返回数据框)
- `group_map()` return a list of tibble(返回元素均为df的一个列表list(df1,df2,df3))

数据框进来,然后分组,依次处理成一个个数据框,最后以列表形式(a list of tibble)输出。


Expand Down
Loading

0 comments on commit 8ec824f

Please sign in to comment.