-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmap&geom_shape.R
81 lines (61 loc) · 1.83 KB
/
map&geom_shape.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
library(tidyverse)
map(iris, mean)
map_df(iris, mean)
map_df(iris[1:4], mean)
mtcars
print_mpg = function(x, y){
paste(x,"gets",y,"miles per gallon")
}
map2_chr( # char output
rownames( mtcars ), # carnames are in the rows
mtcars$mpg, # column
print_mpg # function
)
map2_chr(rownames(mtcars),
mtcars$mpg,
function(x,y)
paste(x,"gets",y,"miles per gallon")
)
peng = palmerpenguins::penguins
print_body_mass = function(x, y){
paste(x, "has", y, "body mass")
}
map2_chr(
rownames(peng), # length of rows in df
peng$body_mass_g, # column
print_body_mass
)
ggplot(
mtcars,
aes(x= mpg,
y= cyl,
fill= as.character(carb),
# shape= as.character(gear),
size= as.character(gear),
color= as.character(gear)
)
)+
geom_point(
# size=4,
stroke= 1.2)+
scale_shape_manual(breaks = c(3, 4, 5),
values = c(21,24,22)
# guide= guide_legend(override.aes = list(fill='green',
# color='green'))
)+
scale_color_manual(breaks= c(3,4,5),
# values = c('purple','orange','green')
values = c('green','purple',
'red')
)+
scale_size_manual(breaks = c(3,4,5),
values = c(3,4,5))+
scale_fill_manual(breaks = c(1,2,3,4,6,8),
values = rainbow(6),
guide= guide_legend(override.aes = list(color= rainbow(6),
shape= 18,
size=5
)
)
)+
ggdark::dark_mode()