Здравствуйте, в этом домашнем задании нужно сделать:1) Заголовки, 2)Форматирование, 3)Иллюстрации, 4)Таблицы, 5) Код.
Взяла с домашнего задания
cs <- read_excel("Caspian spiders.xlsx") %>%
pivot_longer(names_to = "sp", values_to = "abu",
-c("id", "plants.d", "coast", "RH"))
df <- cs %>%
filter( abu >0) %>%
group_by(id, coast, plants.d, RH) %>%
summarise(S = n(),
N = sum(abu),
RH = mean(RH, na.rm=TRUE),
groups = "drop") %>%
mutate(index = ((S-1) / sqrt(N))) %>%
ungroup()
fit <- lm(index ~ RH, data = df)
ggplot(df,mapping = aes(x = RH, y = index)) +
geom_point(color = "brown",
size = 3) +
geom_abline(slope = fit$coefficients[2],
intercept = fit$coefficients[1],
color = "purple",
size= 2) +
labs(x = "Влажность", y = "Индекс Менхиника",
title = "Зависимость индекса Менхиника от влажности") +
theme_light()
df
## # A tibble: 73 × 8
## id coast plants.d RH S N groups index
## <chr> <chr> <chr> <dbl> <int> <dbl> <chr> <dbl>
## 1 PbAe1 pebbly Aeluropus 32.0 1 1 drop 0
## 2 PbAe3 pebbly Aeluropus 32.0 2 2 drop 0.707
## 3 PbAe5 pebbly Aeluropus 32.8 1 1 drop 0
## 4 PbDe1 pebbly Deschampsia 29.7 2 2 drop 0.707
## 5 PbDe2 pebbly Deschampsia 32.0 2 2 drop 0.707
## 6 PbDe3 pebbly Deschampsia 30.6 1 4 drop 0
## 7 PbDe4 pebbly Deschampsia 28.2 5 29 drop 0.743
## 8 PbDe5 pebbly Deschampsia 34.0 3 35 drop 0.338
## 9 PbPo1 pebbly Poa 27.5 3 4 drop 1
## 10 PbPo2 pebbly Poa 32.9 1 2 drop 0
## # ℹ 63 more rows
formattable::formattable(df)
| id | coast | plants.d | RH | S | N | groups | index |
|---|---|---|---|---|---|---|---|
| PbAe1 | pebbly | Aeluropus | 31.9717600 | 1 | 1 | drop | 0.0000000 |
| PbAe3 | pebbly | Aeluropus | 31.9802909 | 2 | 2 | drop | 0.7071068 |
| PbAe5 | pebbly | Aeluropus | 32.8219433 | 1 | 1 | drop | 0.0000000 |
| PbDe1 | pebbly | Deschampsia | 29.7359357 | 2 | 2 | drop | 0.7071068 |
| PbDe2 | pebbly | Deschampsia | 31.9729330 | 2 | 2 | drop | 0.7071068 |
| PbDe3 | pebbly | Deschampsia | 30.5540613 | 1 | 4 | drop | 0.0000000 |
| PbDe4 | pebbly | Deschampsia | 28.2292156 | 5 | 29 | drop | 0.7427814 |
| PbDe5 | pebbly | Deschampsia | 33.9622642 | 3 | 35 | drop | 0.3380617 |
| PbPo1 | pebbly | Poa | 27.5301205 | 3 | 4 | drop | 1.0000000 |
| PbPo2 | pebbly | Poa | 32.8936743 | 1 | 2 | drop | 0.0000000 |
| PbPo3 | pebbly | Poa | 33.7974684 | 10 | 49 | drop | 1.2857143 |
| PbPo4 | pebbly | Poa | 34.0253165 | 5 | 53 | drop | 0.5494423 |
| PbPo5 | pebbly | Poa | 24.2591316 | 3 | 10 | drop | 0.6324555 |
| PbTl1 | pebbly | Typha | 31.9814600 | 1 | 1 | drop | 0.0000000 |
| PbTl2 | pebbly | Typha | 28.5714286 | 11 | 43 | drop | 1.5249857 |
| PbTl3 | pebbly | Typha | 30.0776915 | 9 | 24 | drop | 1.6329932 |
| PbTl4 | pebbly | Typha | 33.5314685 | 5 | 16 | drop | 1.0000000 |
| PbTl5 | pebbly | Typha | 26.9458712 | 12 | 53 | drop | 1.5109662 |
| PbTu1 | pebbly | Typha | 32.8875090 | 8 | 26 | drop | 1.3728129 |
| PbTu2 | pebbly | Typha | 32.4273664 | 13 | 75 | drop | 1.3856406 |
| PbTu3 | pebbly | Typha | 31.5101899 | 13 | 146 | drop | 0.9931271 |
| PbTu4 | pebbly | Typha | 30.8875360 | 6 | 8 | drop | 1.7677670 |
| PbTu5 | pebbly | Typha | 32.4981017 | 14 | 38 | drop | 2.1088785 |
| RsFd1 | reeds | Phragmites | 24.5621181 | 19 | 98 | drop | 1.8182746 |
| RsFd2 | reeds | Phragmites | 26.6263238 | 14 | 52 | drop | 1.8027756 |
| RsFd3 | reeds | Phragmites | 26.2936475 | 16 | 62 | drop | 1.9050019 |
| RsFd4 | reeds | Phragmites | 28.8649204 | 16 | 106 | drop | 1.4569288 |
| RsFd5 | reeds | Phragmites | 31.9535588 | 16 | 203 | drop | 1.0527936 |
| SdCJ1 | dunes | Convolvulus | 3.3097686 | 2 | 3 | drop | 0.5773503 |
| SdCJ2 | dunes | Convolvulus | 5.5804340 | 2 | 3 | drop | 0.5773503 |
| SdCJ3 | dunes | Convolvulus | 9.8338870 | 2 | 6 | drop | 0.4082483 |
| SdCJ4 | dunes | Convolvulus | 6.5529923 | 1 | 2 | drop | 0.0000000 |
| SdCJ5 | dunes | Convolvulus | 6.5536355 | 1 | 1 | drop | 0.0000000 |
| SdCS1 | dunes | Convolvulus | 2.2787029 | 6 | 25 | drop | 1.0000000 |
| SdCS2 | dunes | Convolvulus | 1.3902681 | 5 | 27 | drop | 0.7698004 |
| SdCS3 | dunes | Convolvulus | 2.6631158 | 5 | 37 | drop | 0.6575959 |
| SdCS4 | dunes | Convolvulus | 1.1450382 | 5 | 33 | drop | 0.6963106 |
| SdCS5 | dunes | Convolvulus | 0.5416667 | 5 | 28 | drop | 0.7559289 |
| SdEc1 | sandy beach | Elaeagnus | 19.3536122 | 6 | 15 | drop | 1.2909944 |
| SdEc2 | sandy beach | Elaeagnus | 28.0592362 | 9 | 181 | drop | 0.5946353 |
| SdEc3 | sandy beach | Elaeagnus | 28.5611511 | 14 | 278 | drop | 0.7796882 |
| SdEc4 | sandy beach | Elaeagnus | 14.2454161 | 9 | 38 | drop | 1.2977714 |
| SdEc5 | sandy beach | Elaeagnus | 29.3262239 | 15 | 112 | drop | 1.3228757 |
| SdEq1 | sandy beach | Equisetum | 25.9322034 | 9 | 55 | drop | 1.0787198 |
| SdEq2 | sandy beach | Equisetum | 23.0835985 | 7 | 48 | drop | 0.8660254 |
| SdEq3 | sandy beach | Equisetum | 23.0694354 | 7 | 14 | drop | 1.6035675 |
| SdEq4 | sandy beach | Equisetum | 26.0514019 | 8 | 34 | drop | 1.2004901 |
| SdEq5 | sandy beach | Equisetum | 25.3725332 | 5 | 80 | drop | 0.4472136 |
| SdFn1 | sandy beach | Phragmites | 47.7828429 | 12 | 146 | drop | 0.9103665 |
| SdFn2 | sandy beach | Phragmites | 45.3157895 | 16 | 156 | drop | 1.2009612 |
| SdFn3 | sandy beach | Phragmites | 28.0857952 | 10 | 65 | drop | 1.1163126 |
| SdFn4 | sandy beach | Typha | 22.1399482 | 7 | 16 | drop | 1.5000000 |
| SdFn5 | sandy beach | Typha | 29.9861496 | 11 | 19 | drop | 2.2941573 |
| SdJj1 | sandy beach | Juncus | 27.0052734 | 10 | 144 | drop | 0.7500000 |
| SdJj2 | sandy beach | Juncus | 26.4773379 | 7 | 82 | drop | 0.6625892 |
| SdJj3 | sandy beach | Juncus | 28.0619298 | 4 | 8 | drop | 1.0606602 |
| SdJj4 | sandy beach | Juncus | 27.1174119 | 6 | 64 | drop | 0.6250000 |
| SdJj5 | sandy beach | Juncus | 30.6015038 | 7 | 44 | drop | 0.9045340 |
| SdJm1 | sandy beach | Juncus | 25.3587024 | 9 | 97 | drop | 0.8122769 |
| SdJm2 | sandy beach | Juncus | 24.8106744 | 7 | 30 | drop | 1.0954451 |
| SdJm3 | sandy beach | Juncus | 20.2730375 | 10 | 68 | drop | 1.0914103 |
| SdJm4 | sandy beach | Juncus | 24.7879722 | 3 | 85 | drop | 0.2169305 |
| SdJm5 | sandy beach | Juncus | 24.2492492 | 5 | 21 | drop | 0.8728716 |
| SdTa1 | sandy beach | Typha | 28.5714286 | 8 | 57 | drop | 0.9271726 |
| SdTa2 | sandy beach | Typha | 25.9383129 | 11 | 79 | drop | 1.1250879 |
| SdTa3 | sandy beach | Typha | 29.5734101 | 12 | 267 | drop | 0.6731891 |
| SdTa4 | sandy beach | Typha | 30.5990080 | 6 | 11 | drop | 1.5075567 |
| SdTa5 | sandy beach | Typha | 25.5667038 | 6 | 20 | drop | 1.1180340 |
| SdTu1 | sandy beach | Typha | 23.6719082 | 8 | 130 | drop | 0.6139406 |
| SdTu2 | sandy beach | Typha | 22.4859875 | 8 | 41 | drop | 1.0932163 |
| SdTu3 | sandy beach | Typha | 23.0740464 | 9 | 50 | drop | 1.1313708 |
| SdTu4 | sandy beach | Typha | 24.1089307 | 6 | 12 | drop | 1.4433757 |
| SdTu5 | sandy beach | Typha | 22.6672172 | 7 | 15 | drop | 1.5491933 |
На это всё!