add some lesson for lesson6
This commit is contained in:
91
SD/1.1_R语言介绍/_demo.qmd
Normal file
91
SD/1.1_R语言介绍/_demo.qmd
Normal file
@@ -0,0 +1,91 @@
|
||||
---
|
||||
title: "Lesson 6"
|
||||
format: html
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
```{r}
|
||||
|
||||
https://rs1.drwater.net
|
||||
|
||||
username:
|
||||
- ruser01
|
||||
- ruser02
|
||||
- ruser03
|
||||
- ruser04
|
||||
- ruser05
|
||||
- ruser06
|
||||
|
||||
RWEP2025
|
||||
|
||||
```
|
||||
|
||||
|
||||
# 安装包
|
||||
|
||||
|
||||
```{r}
|
||||
install.packages("tidyverse")
|
||||
|
||||
x <- c(1:10, NA)
|
||||
|
||||
hist(x)
|
||||
|
||||
mean(x, na.rm = TRUE)
|
||||
|
||||
median(x, na.rm = TRUE)
|
||||
|
||||
sd(x, na.rm = TRUE)
|
||||
|
||||
|
||||
for(i in 1:10){
|
||||
print(i)
|
||||
}
|
||||
|
||||
|
||||
x + y + x * y
|
||||
|
||||
myfunc <- function(x, y = 3) {
|
||||
x + y + x * y
|
||||
}
|
||||
|
||||
|
||||
myfunc(1, 2)
|
||||
|
||||
|
||||
myfunc(10)
|
||||
|
||||
|
||||
c(FALSE, 2, 1:3, 3)
|
||||
|
||||
c(FALSE, 2, 1:3, 3) > 1
|
||||
|
||||
all(c(FALSE, 2, 1:3, 3) > 1)
|
||||
|
||||
|
||||
c(1L,2L,3L)
|
||||
|
||||
any(c(FALSE, 2, 1:3, 3) > 1)
|
||||
|
||||
|
||||
x <- 10
|
||||
|
||||
sin(x) = ?
|
||||
|
||||
paste("sin(x) = ", sin(x), sep = " ")
|
||||
|
||||
paste0("sin(x) = ", sin(x))
|
||||
|
||||
|
||||
substr("Monday", 1, 3)
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user