2024-03-25 22:11:41 +08:00
|
|
|
|
---
|
|
|
|
|
title: "〇、R语言实践前篇"
|
|
|
|
|
subtitle: 《区域水环境污染数据分析实践》<br>Data analysis practice of regional water environment pollution
|
|
|
|
|
author: 苏命、王为东<br>中国科学院大学资源与环境学院<br>中国科学院生态环境研究中心
|
|
|
|
|
date: today
|
|
|
|
|
lang: zh
|
|
|
|
|
format:
|
|
|
|
|
revealjs:
|
|
|
|
|
theme: dark
|
|
|
|
|
slide-number: true
|
|
|
|
|
chalkboard:
|
|
|
|
|
buttons: true
|
|
|
|
|
preview-links: auto
|
|
|
|
|
lang: zh
|
|
|
|
|
toc: true
|
|
|
|
|
toc-depth: 1
|
|
|
|
|
toc-title: 大纲
|
|
|
|
|
logo: ./_extensions/inst/img/ucaslogo.png
|
|
|
|
|
css: ./_extensions/inst/css/revealjs.css
|
|
|
|
|
pointer:
|
|
|
|
|
key: "p"
|
|
|
|
|
color: "#32cd32"
|
|
|
|
|
pointerSize: 18
|
|
|
|
|
revealjs-plugins:
|
|
|
|
|
- pointer
|
|
|
|
|
filters:
|
|
|
|
|
- d2
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
```{r}
|
|
|
|
|
#| include: false
|
|
|
|
|
#| cache: false
|
|
|
|
|
lang <- "cn"
|
|
|
|
|
require(tidyverse)
|
|
|
|
|
knitr::opts_chunk$set(echo = TRUE)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## R语言实践部分课程简介
|
|
|
|
|
|
|
|
|
|
**接下来的课程由我来带着大家一起学习、实践基于R语言的数据分析。**
|
|
|
|
|
|
|
|
|
|
### 自我介绍
|
|
|
|
|
|
|
|
|
|
- 苏命:来自中国科学院生态环境研究中心
|
|
|
|
|
- 主要从事**水源水质水生态**方面的研究
|
|
|
|
|
|
|
|
|
|
### 课件
|
|
|
|
|
|
|
|
|
|
- 采用`R语言`+`quarto`完成
|
|
|
|
|
- 网页公开:[https://drwater.rcees.ac.cn/course/public/RWEP/\@PUB/index.html](https://drwater.rcees.ac.cn/course/public/RWEP/@PUB/index.html)
|
|
|
|
|
- 课件代码:[https://drwater.rcees.ac.cn/git/course/RWEP.git](https://drwater.rcees.ac.cn/git/course/RWEP.git)
|
2024-03-26 16:58:06 +08:00
|
|
|
|
- 代码web界面:[https://on.tty-share.com/s/ny3JVrMuvUNOmnuioS3I7YEeVCi5Hk3Qc9vgz2QdX0FE2cYAQZFW2MUOkQyG0P5ZUR8/](https://on.tty-share.com/s/ny3JVrMuvUNOmnuioS3I7YEeVCi5Hk3Qc9vgz2QdX0FE2cYAQZFW2MUOkQyG0P5ZUR8/)
|
2024-03-25 22:11:41 +08:00
|
|
|
|
|
|
|
|
|
## 如何学习接下来的内容?
|
|
|
|
|
|
|
|
|
|
- 上课形式:
|
|
|
|
|
- **实践操作为主**,目的是让每一位同学都能独立开展基于R的数据分析
|
|
|
|
|
- **2-3人一组**,自由分组,相互帮助
|
|
|
|
|
- 准备工作:
|
|
|
|
|
- 个人笔记本电脑,Microsoft Windows、GNU/Linux、MacOS系统
|
|
|
|
|
- 安装好**Microsoft Excel**
|
|
|
|
|
- 能联网
|
|
|
|
|
- 如果电池不够用,建议带上插座
|
|
|
|
|
- 上课规则
|
|
|
|
|
- 可随时打断,**不懂就问**
|
|
|
|
|
- **无特殊情况不迟到**,否则操作过程容易跟不上
|
|
|
|
|
|
|
|
|
|
## Rstudio Server使用
|
|
|
|
|
|
|
|
|
|
- 服务网址:[https://drwater.rcees.ac.cn/rs1/](https://drwater.rcees.ac.cn/rs1/)
|
|
|
|
|
- 每位同学使用1个账号,随机生成
|
|
|
|
|
- 密码:****
|
|
|
|
|
- 后面的实践课程可在该服务器上完成
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 请记住自己的账号!
|
|
|
|
|
|
|
|
|
|
::: {layout-ncol=2}
|
|
|
|
|
|
|
|
|
|
```{r}
|
|
|
|
|
#| echo: false
|
|
|
|
|
#| output: asis
|
|
|
|
|
coursememberdf <- readxl::read_xlsx("../../data/course_member.xlsx")
|
|
|
|
|
nmem <- nrow(coursememberdf)
|
|
|
|
|
set.seed <- 23
|
|
|
|
|
|
|
|
|
|
uiddf <- coursememberdf |>
|
|
|
|
|
dplyr::mutate(uid = paste0("ruser", sprintf("%02d", sample(1:nmem, nmem)))) |>
|
|
|
|
|
dplyr::select(uid, 姓名) |>
|
|
|
|
|
dplyr::mutate(姓名 = "XX") |>
|
|
|
|
|
dplyr::arrange(uid) |>
|
|
|
|
|
dplyr::mutate(group = (dplyr::row_number() - 1) %/% 10 + 1) |>
|
|
|
|
|
tidyr::nest(gdf = -group) |>
|
|
|
|
|
dplyr::mutate(tab = purrr::map(gdf, ~ knitr::kable(.x)))
|
|
|
|
|
|
|
|
|
|
uiddf$tab[[1]]
|
|
|
|
|
uiddf$tab[[2]]
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
## 请记住自己的账号!
|
|
|
|
|
|
|
|
|
|
::: {layout-ncol=2}
|
|
|
|
|
|
|
|
|
|
```{r}
|
|
|
|
|
#| echo: false
|
|
|
|
|
#| output: asis
|
|
|
|
|
uiddf$tab[[3]]
|
|
|
|
|
uiddf$tab[[4]]
|
|
|
|
|
```
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
## 课后作业
|
|
|
|
|
|
|
|
|
|
提交形式:`第*次作业_姓名.qmd`文件
|
|
|
|
|
|
|
|
|
|
模板:
|
|
|
|
|
|
|
|
|
|
````
|
|
|
|
|
---
|
|
|
|
|
title: "课后作业*"
|
|
|
|
|
author: 姓名
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 第1题
|
|
|
|
|
|
|
|
|
|
说明
|
|
|
|
|
|
|
|
|
|
```{r}
|
|
|
|
|
# Here is the code
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# 第2题
|
|
|
|
|
|
|
|
|
|
说明
|
|
|
|
|
|
|
|
|
|
```{r}
|
|
|
|
|
# Here is the code
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
````
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 欢迎讨论!{.center}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
`r rmdify::slideend(wechat = FALSE, type = "public", tel = FALSE, thislink = "../")`
|