forked from hoasxyz/even-website
/
Rdata.R
65 lines (53 loc) 路 1.42 KB
/
Rdata.R
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
.libPaths("E:/R-3.5.2/library")
install.packages("tibble")
library(tibble)
detach("package:tibble")
detach("package:tidyverse")
install.packages("installr")
library(installr)
updateR()
packageVersion("tibble")
devtools::install_github('tidyverse/tibble')
library("devtools")
install_version("tibble",version="2.0.0")
# 2xi'an -----------------------------------------------------------------------
require(leaflet)
require(readxl)
options(digits = 10)
xian <- read_xlsx("E:/!Learning_R_is_awesome!/my website/xian.xlsx")
xian$property <- as.factor(xian$property)
getcolor <- function(xian) {
sapply(xian$property, function(ppt){
if (ppt == 'Tourist') {
"green"
} else if(ppt == 'Station') {
"red"
} else{
"blue"
}
})
}
geticon <- function(xian){
sapply(xian$property, function(ppt){
if (ppt == 'Tourist') {
"eye"
} else if(ppt == 'Station') {
"playstation"
} else{
"beer"
}
})
}
icons <- awesomeIcons(
icon = geticon(xian),
iconColor = 'white',
library = 'ion',
markerColor = getcolor(xian)
)
leaflet(data = xian) %>%
addTiles() %>%
addAwesomeMarkers(~Lon,~Lat,label = ~Place,
popup = ifelse(is.na(xian$Price),as.character(xian$property),
paste("Price(Adult):",xian$Price,"yuan",'<br>',
"Period:",xian$Hours,"hours")),
icon = icons)