R Language (Сковорцов) / Анализ данных на языке R
.pdfgeom_smooth(method = "lm")
ggplot(diamonds, aes(carat))+
geom_density(alpha = .1) +
facet_wrap( ~ cut, ncol = 1)
ggplot(diamonds, aes(carat))+
geom_density(alpha = .1) +
facet_grid(cut ~ .)
ggplot(diamonds, aes(carat, price))+
geom_smooth() +
facet_grid(color ~ .)
seq_x <- round(seq(min(mtcars$mpg), max(mtcars$mpg), length.out = 5))
ggplot(mtcars, aes(x = mpg, y = hp, col = factor(am))) + geom_point() +
scale_x_continuous(name = "Miles/(US) gallon", breaks = c(1, seq(10, 35, 5)),
limits = c(1, 35)) + scale_y_continuous(limits = c(50, 400)) + scale_color_manual(values = c("Blue", "Black"),
name = "Legend name", labels = c("Auto", "Manual"))
ggplot(mtcars, aes(hp, fill = factor(am)))+ geom_density(alpha = 0.2) + scale_fill_manual(values = c("Red", "Green"))
ggplot(mtcars, aes(hp, mpg, size = disp, shape = factor(vs))) + geom_point() +
scale_size_continuous(name = "Any name", breaks = seq(100, 400, 40)) + scale_shape_discrete(name = "Any name")
ggplot(mtcars, aes(factor(am), hp)) + geom_boxplot() + scale_x_discrete()
ggplot(mtcars, aes(factor(am), hp, fill = factor(cyl))) + geom_boxplot() +
scale_fill_brewer(type = "qual", palette = 3) + theme_bw()
ggplot(mtcars, aes(hp, mpg, col = factor(cyl))) + geom_point(size = 5) + scale_color_brewer(type = "qual", palette = 6) + theme_dark()
install.packages("ggthemes")
library("ggthemes")
ggplot(mtcars, aes(hp, mpg, col = factor(cyl))) + geom_point(size = 2) +
theme()
p <- ggplot(d, aes(date, percent, col = system, group = system))+ geom_line(size = 1.3) +
geom_point(shape = 21, size = 4, fill = "black") + geom_point(shape = 21, size = 3.5) + geom_point(shape = 21, size = 3) + geom_vline(xintercept = 7.5, color = "white",
linetype = "dotted") + scale_y_continuous(breaks = c(0, .04, .08, .11, .15),
limits = c(0, .15),
labels = scales::percent) + scale_color_manual(values = c("orangered1",
"red",
"cyan",
"yellow1", "springgreen2")) +
xlab("")+
ylab("")+
ggtitle("Top 5 Linux distributions (% of total per year)")+ theme_classic()
p + theme(legend.title = element_blank(), legend.position = "top",
plot.background = element_rect(color = "black", fill = "black"),
panel.background = element_rect(color = "black", fill = "black"),
legend.background = element_rect(fill = "black"), text = element_text(color = "white"), panel.grid.major.y = element_line(color = "gray50",
linetype = "longdash", size = 0.3),
axis.text.x = element_text(face = "bold", size = 16), axis.text.y = element_text(face = "bold", size = 14), legend.text = element_text(size = 14),
title = element_text(face = "bold", size = 16))
library(grid)
grid.text("Data sourse: The DistroWatch's Page Hit Ranking (Nov. 23, 2011)",
x = 0.02, y = 0.01, just = c("left", "bottom"),
gp = gpar(fontface = "bold", fontsize = 9, col = "white"))
grid.text("www.pingdom.com",
x = 0.98, y = 0.01, just = c("right", "bottom"),
gp = gpar(fontface = "bold", fontsize = 9, col = "white"))