-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathideas_draft.R
169 lines (154 loc) · 5.18 KB
/
ideas_draft.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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#.........................................................
## MAYBE IDEAS FOR LATER
#.........................................................
##### ANIMATED PLOTS
#
# # libraries:
# library(ggplot2)
# library(gganimate)
# library(babynames)
# library(hrbrthemes)
#
# # Keep only 3 names
# don <- babynames %>%
# filter(name %in% c("Ashley", "Patricia", "Helen")) %>%
# filter(sex=="F")
#
# # Plot
# don %>%
# ggplot( aes(x=year, y=n, group=name, color=name)) +
# geom_line() +
# geom_point() +
# ggtitle("Popularity of American names in the previous 30 years") +
# theme_ipsum() +
# ylab("Number of babies born") +
# transition_reveal(year)
#
#
#
# # Save at gif: does
# anim_save("287-smooth-animation-with-tweenr.gif")
#
#
#
# #--------------------------------------------------------------
# # OR
# #--------------------------------------------------------------
#
#
# #https://www.datanovia.com/en/blog/gganimate-how-to-create-plots-with-beautiful-animation-in-r/
#
#
#
#
#
#
# #Grafico de acumulada de numero de buceos
#
# #------------------------------------------------------------
#
# # Polygons with Label as formula and custom label options
# leaflet(cities) %>% addTiles() %>%
# addCircles(lng = ~Long, lat = ~Lat, weight = 1,
# radius = ~sqrt(Pop) * 30, label = ~City,
# labelOptions = lapply(1:nrow(cities), function(x) {
# labelOptions(opacity = 0.8)
# }))
# <br/><br/>
#--------------------------------------------------------------
## https://stackoverflow.com/questions/32940617/change-color-of-leaflet-marker
# Icons libraries
# fa - https://fontawesome.com/v4.7.0/icons/
# glyphicon - https://getbootstrap.com/docs/3.3/components/
# ionicicons - https://ionicons.com/
#
# mutate(scuba_map, group = cut(as.numeric(scuba_map$maximumDepthInMeters) , breaks = c(5, 10, 15, 20, 25, 30, Inf), labels = c("pink", "lightblue", "blue", "cadetblue", "darkblue", "darkpurple"))) -> mydf
#
# ### I edit this png file and created my own marker.
# ### https://raw.githubusercontent.com/lvoogdt/Leaflet.awesome-markers/master/dist/images/markers-soft.png
# scubaIcons <- awesomeIconList(pink = makeAwesomeIcon(icon= 'cloud', markerColor = 'pink', iconColor = 'black'),
# lightblue = makeAwesomeIcon(icon= 'cloud', markerColor = 'lightblue', iconColor = 'black'),
# blue = makeAwesomeIcon(icon= 'cloud', markerColor = 'blue', iconColor = 'black'),
# cadetblue = makeAwesomeIcon(icon= 'cloud', markerColor = 'cadetblue', iconColor = 'black'),
# darkblue = makeAwesomeIcon(icon= 'cloud', markerColor = 'darkblue', iconColor = 'black'),
# darkpurple = makeAwesomeIcon(icon= 'cloud', markerColor = 'darkpurple', iconColor = 'black'))
#
# scubaIcons
#
# leaflet(data = mydf[1:100,]) %>%
# addTiles() %>%
# addMarkers(icon = ~scubaIcons$group)
#
#
#
# icon.glyphicon <- makeAwesomeIcon(icon= 'cloud', markerColor = 'red', iconColor = 'black')
# icon.fa <- makeAwesomeIcon(icon = 'flag', markerColor = 'mediumorchid1', library='fa', iconColor = 'black')
# icon.ion <- makeAwesomeIcon(icon = 'home', markerColor = 'green', library='ion')
#
#
#
# library(dplyr)
# library(leaflet)
#
#
#
# data(quakes)
#
# # Show first 20 rows from the `quakes` dataset
# leaflet(data = quakes[1:100,]) %>% addTiles() %>%
# addMarkers(~long, ~lat, popup = ~as.character(mag))
#
# #___________________________________________________________
#
# mutate(quakes, group = cut(mag, breaks = c(0, 5, 6, Inf), labels = c("blue", "green", "orange"))) -> mydf
#
# ### I edit this png file and created my own marker.
# ### https://raw.githubusercontent.com/lvoogdt/Leaflet.awesome-markers/master/dist/images/markers-soft.png
# quakeIcons <- iconList(blue = makeIcon("./image_example_map.png", iconWidth = 24, iconHeight =32),
# green = makeIcon("./image_example_map.png", iconWidth = 30, iconHeight =50),
# orange = makeIcon("./image_example_map.png", iconWidth = 12, iconHeight =20))
#
#
# leaflet(data = mydf[1:100,]) %>%
# addTiles() %>%
# addMarkers(icon = ~quakeIcons[group])
#
#
#
#
# # Marker + Label
# leaflet() %>% addTiles() %>%
# addAwesomeMarkers(
# lng=-118.456554, lat=34.078039,
# label='This is a label',
# icon = icon.glyphicon)
#
# leaflet() %>% addTiles() %>%
# addAwesomeMarkers(
# lng=-118.456554, lat=34.078039,
# label='This is a label',
# icon = icon.fa)
#
# leaflet() %>% addTiles() %>%
# addAwesomeMarkers(
# lng=-118.456554, lat=34.078039,
# label='This is a label',
# icon = icon.ion)
#
# # Marker + Static Label using custom label options
# leaflet() %>% addTiles() %>%
# addAwesomeMarkers(
# lng=-118.456554, lat=34.078039,
# label='This is a static label',
# labelOptions = labelOptions(noHide = T),
# icon = icon.fa)
# Plotly plots
#
# load("data/scuba_map.RData")
# library(plotly)
#
# fig <- plot_ly(data = scuba_map %>% filter (!is.na(maximumDepthInMeters)),
# x = ~as.Date(eventDate),
# y = ~-as.numeric(maximumDepthInMeters))
#
# fig