Commit 20dcfa59 authored by Nicolas Lambert's avatar Nicolas Lambert
Browse files

vignette

parent 2b1a101b
......@@ -9,7 +9,7 @@
#' @param type type of flows, "rect" (for rectangles) or "arrows" (for arrows), default is "arrows".
#' @param decreasing display order, default is FALSE.
#' @param add whether to add the layer to an existing plot (TRUE) or not (FALSE), default is TRUE
#' @param lwd borders width, default is 1.
#' @param lwd flows borders width, default is 1.
#' @param col color of flows, default is "#00FF0090"
#' @param border color of flows borders, default is "#4a0c25"
#' @param k value to increase or decrease the size of the flows (in units of the map), default is NULL. To be improved...
......@@ -17,6 +17,9 @@
#' @param df2id name of the numeric field in df2, default is "id"
#' @param df2var name of the numeric variable to plot circles.
#' @param k2 value to increase or decrease the size of the circles (in units of the map), default is NULL. To be improved...
#' @param col2 color of circles, default is NULL
#' @param border2 color of circles borders, default is "black"
#' @param lwd2 circles borders width, default is 1
#'
#' @return
#' @export
......@@ -112,7 +115,10 @@ plotflows <- function(
df2 = NULL,
df2id = "id",
df2var,
k2 = NULL
k2 = NULL,
col2 = NULL,
border2 = "black",
lwd2 = 1
){
......@@ -135,7 +141,7 @@ plotflows <- function(
flows <- linktoflows(links, size, k = k, dfvar, type, decreasing)
plot(st_geometry(flows), col =col, add = add)
plot(st_geometry(c), col = NA, border = "black", lwd = 2, add = TRUE)
plot(st_geometry(c), col = col2, border = border2, lwd = lwd2, add = TRUE)
output <- list("links" = links, "circles" = c, "flows" = flows)
return(output)
......
......@@ -21,7 +21,10 @@ plotflows(
df2 = NULL,
df2id = "id",
df2var,
k2 = NULL
k2 = NULL,
col2 = NULL,
border2 = "black",
lwd2 = 1
)
}
\arguments{
......@@ -43,7 +46,7 @@ plotflows(
\item{add}{whether to add the layer to an existing plot (TRUE) or not (FALSE), default is TRUE}
\item{lwd}{borders width, default is 1.}
\item{lwd}{flows borders width, default is 1.}
\item{col}{color of flows, default is "#00FF0090"}
......@@ -58,6 +61,12 @@ plotflows(
\item{df2var}{name of the numeric variable to plot circles.}
\item{k2}{value to increase or decrease the size of the circles (in units of the map), default is NULL. To be improved...}
\item{col2}{color of circles, default is NULL}
\item{border2}{color of circles borders, default is "black"}
\item{lwd2}{circles borders width, default is 1}
}
\value{
......
......@@ -7,26 +7,31 @@ vignette: >
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```{r echo=FALSE}
knitr::opts_chunk$set(collapse = TRUE,
fig.width = 7.2,
fig.height = 4,
margin = TRUE)
knitr::knit_hooks$set(margin = function(before, options, envir){
if (before){
par(mar=c(0,0,0,0))
}
})
```
Install
# Install
```{r eval= FALSE}
devtools::install_git(url = "https://gitlab.huma-num.fr/nlambert/flowmapper")
```
Load
# Load
```{r}
library(flowmapper)
```
Data Import & Handling
# Data Import & Handling
```{r out.width = 200}
library(sf)
......@@ -43,7 +48,7 @@ threshold <- 1500
migr <- migr[migr$fij >= threshold,]
```
Example 1
# Example 1
```{r}
c <- plotflows(
......@@ -55,7 +60,7 @@ c <- plotflows(
)
```
Example 2
# Example 2
```{r}
intra <- migr[migr$i == migr$j,c("i","fij")]
......@@ -83,7 +88,7 @@ c <- plotflows(
```
Example 3
# Example 3
```{r}
crs <- "+proj=aeqd +lat_0=90 +lon_0=50 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs "
......@@ -100,7 +105,7 @@ c <- plotflows(
)
```
Example 4
# Example 4
```{r}
crs <- "+proj=ortho +lat_0=42.5333333333 +lon_0=-72.53333333339999 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment