-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
92 lines (53 loc) · 2.01 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# Lab3package
<!-- badges: start -->
<!-- badges: end -->
The goal of Lab3package is to thin the large shape files and convert it into a data frame containing Longitude, Latitude, group, order and NAME_1 or HASC_1 so that you can make a polygon figure colored by region(NAME_1 or HASC_1) using this data frame.
## Installation
You can install the development version of Lab3package from [GitHub](https://github.com/) with:
```{r, eval=FALSE, echo=TRUE}
# install.packages("devtools")
devtools::install_github("JinjiPang/Lab3package")
```
## Example
This is a basic example to show how to use functions in this package to create geometric data frame and some implementations.
```{r data example}
library(Lab3package)
data("Yemen")
```
First, you can download a shape file of a country of your choice. Then, you can either read the file using `sf::read_sf()`first or just use the file path to try the following codes:
#### team_2
This function will return a data frame with four basic variables, which are long, lat, order, and group.
```{r }
library(tidyverse)
df1 <- team_2(Yemen, 0.1)
df1 %>%
ggplot(aes(x = long, y = lat, group = group)) + geom_polygon()
```
#### team_5
This function will return a data frame with five basic variables, which are long, lat, order, group, and HASC_1.
```{r }
library(tidyverse)
df2 <- team_5(Yemen, 0.1)
df2 %>%
ggplot(aes(x = long, y = lat, group = group)) + geom_polygon(aes(fill = HASC_1))
```
#### team_6
This function will return a data frame with 15 variables, basically it keeps all the original variables and add three more variables long, lat, group, order and NAME_1.
```{r }
library(tidyverse)
df3 <- team_6(Yemen, 0.1)
df3 %>%
ggplot(aes(x = long, y = lat, group = group)) + geom_polygon(aes(fill = NAME_1))
```