forked from privefl/rmarkdown-website-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
members.Rmd
95 lines (81 loc) · 3.21 KB
/
members.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
90
91
92
93
94
---
title: "About our community"
editor_options:
chunk_output_type: console
---
## Where are we?
```{r, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(dplyr)
# install.packages("googlesheets4")
library(googlesheets4)
# install.packages(c("leaflet", "DT"))
library(leaflet)
library(DT)
gs4_auth("[email protected]")
```
```{r, include=FALSE}
members <- read_sheet("1WyfmLfoAQUP2iRogqcOfYA9Hum7DT0BcVyTtei_6Xjw") %>%
tidyr::unite(`First name`, `Last name`, col = "Name", sep = " ") %>%
mutate(
Name = if_else(is.na(Website), Name,
paste0("<a href='", Website, "' target='_blank'>", Name, "</a>")),
Website = NULL,
Status = if_else(is.na(Status), "member", Status),
infos = paste0(
Name, "<br>",
if_else(is.na(Institution), "", paste0("at ", Institution, "<br>")),
if_else(is.na(Field), "", paste0("in ", Field, "<br>")),
if_else(is.na(Keywords), "", paste0("knows ", Keywords))
)
)
# check wrong entries for status
stopifnot(all(members$Status %in% c("member", "referent", "admin")))
# check for duplicates
stopifnot(nrow(members %>% group_by(Name) %>% filter(n() > 1)) == 0)
```
```{r, message=FALSE}
# display map
suppressWarnings(
leaflet(members, width = "100%") %>%
setView(lng = 5.767249, lat = 45.190590, zoom = 12) %>%
addTiles(options = providerTileOptions(minZoom = 2, maxZoom = 19)) %>%
addAwesomeMarkers(lng = 5.767249, lat = 45.190590,
popup = "Meeting location",
label = "Meeting location",
icon = makeAwesomeIcon("android-locate", library = "ion", markerColor = "red")) %>%
addAwesomeMarkers(popup = ~infos,
label = ~lapply(infos, htmltools::HTML),
options = markerOptions(riseOnHover = TRUE),
clusterOptions = markerClusterOptions(iconCreateFunction=JS("function (cluster) {
var childCount = cluster.getChildCount();
if (childCount < 5) {
c = 'rgba(100,149,237, 1);'
} else {
c = 'rgba(65,105,225, 1);'
}
return new L.DivIcon({ html: '<div style=\"background-color:'+c+'\"><span>' + childCount + '</span></div>', className: 'marker-cluster', iconSize: new L.Point(40, 40) });
}")),
icon = makeAwesomeIcon("person", library = "ion", markerColor = ~if_else(Status == "member", "blue", "darkblue"))) %>%
htmlwidgets::onRender('
function(el, x) {
var myMap = this;
myMap.on("click", function(e) {
alert("Latitude: " + e.latlng.lat + "\\nLongitude: " + e.latlng.lng)
})
}')
)
```
```{r}
# display table
members %>%
select(Name, Institution, Field, Keywords, Status) %>%
datatable(rownames = FALSE, escape = FALSE)
```
**Status:**
- 'admin' refers to administrators of the website and the mailing list,
- 'referent' refers to dedicated contact persons within institutions,
- 'member' refers to all other members of the community.
<br>
### How to be added?
Please fill the [google doc](https://docs.google.com/spreadsheets/d/1qdG7PPlRCAU8L6Hhq1D2zT0q9LWDUzBfq7mIzz_6Dm8/edit?usp=sharing) (**follow the guidelines!!**) and wait for an admin to upload your data to the actual list of members.