-
Notifications
You must be signed in to change notification settings - Fork 1
/
someCode.R
108 lines (61 loc) · 1.93 KB
/
someCode.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
# cominations
library(combinat)
# all the permutations for 3
p = permn(3)
p
length(permn(3))
# combinations
combi = combinat::combn(3, 2)
combi
# readr::parse_number
n_colors = 10
palette1 = rainbow(n_colors)
pie( rep(1, n_colors),
col = palette1,
main = "grDevices Pkg rainbow()" )
# list all colors
all_colors = grDevices::colors()
all_colors
noGreys = all_colors[grep("gr(a|e)y", grDevices::colors(), invert = T)]
noGreys
palette2 = sample(noGreys, n_colors)
palette2
pie(rep(1, n_colors),
col= palette2,
radius = 1,
main = "grDevice pkg colors()")
library(randomcoloR)
palette4 = distinctColorPalette(n_colors)
palette4
pie(rep(1, n_colors), col= palette4, edges= 100, radius = 5, main = "randomcoloR pkg")
pie(rep(1, n_colors), col = palette4, main = "randomcoloR pkg", edges = 200)
library(crayon)
cat(blue("Hello", "world!\n"))
library(rtrek)
rtrek::st_datasets()
library(trekcolors)
library(trekfont)
library(ggplot2)
library(ggdark)
p <- ggplot(diamonds) +
geom_point(aes(carat, price, color = cut)) +
scale_y_continuous(label = scales::dollar) +
guides(color = guide_legend(reverse = TRUE)) +
labs(title = "Prices of 50,000 round cut diamonds by carat and cut",
x = "Weight (carats)",
y = "Price in US dollars",
color = "Quality of the cut")
# p + theme_gray() # ggplot default
# p + dark_theme_gray()
p + dark_theme_minimal()
invert_geom_defaults() # change geom defaults back to black
library(gapminder)
library(fivethirtyeight)
p <- ggplot(subset(gapminder, continent != "Oceania")) +
geom_line(aes(year, lifeExp, group = country, color = country), lwd = 1, show.legend = FALSE) +
facet_wrap(~ continent) +
scale_color_manual(values = country_colors) +
labs(title = "Life expectancy has increased worldwide")
p + dark_mode(theme_fivethirtyeight())
#> Inverted geom defaults of fill and color/colour.
#> To change them back, use invert_geom_defaults().