Skip to content

Instantly share code, notes, and snippets.

@robintux
Created April 4, 2020 00:50
Show Gist options
  • Save robintux/99455dba57de5328f807fbf2ca2d38b0 to your computer and use it in GitHub Desktop.
Save robintux/99455dba57de5328f807fbf2ca2d38b0 to your computer and use it in GitHub Desktop.
#### Puntos iniciales ####
library(ggplot2)
library(car)
data("Salaries")
p <- ggplot(data = Salaries, aes(x=yrs.service, y=salary,fill = sex))
p + geom_point(aes(shape=sex, color=sex) , size = 3)
p
p + geom_point(aes(shape=sex, color=sex) , size = 3) +
scale_shape_manual(values = c(3,16)) +
scale_color_manual(values = c("red" , "#E69F00"))+
theme(legend.position = "top")
p + geom_point(aes(shape=sex, color=sex) , size = 3) +
scale_shape_manual(values = c(3,16)) +
scale_color_manual(values = c("red" , "#E69F00"))+
theme(legend.position = "top") +
scale_y_continuous(labels = scales::scientific)
p + geom_point(aes(shape=sex, color=sex) , size = 3) +
scale_shape_manual(values = c(3,16)) +
scale_color_manual(values = c("red" , "#E69F00"))+
theme(legend.position = "right") +
scale_y_continuous(labels = scales::scientific)+
geom_smooth() # Regresion LOESS
p + geom_point(aes(shape=sex, color=sex) , size = 3) +
scale_shape_manual(values = c(3,16)) +
scale_color_manual(values = c("red" , "#E69F00"))+
theme(legend.position = "right") +
scale_y_continuous(labels = scales::scientific)+
geom_smooth(method = "lm" , formula = y ~ poly(x,2))
p + geom_point(shape=25)+
geom_smooth(method = "lm" , color = "black", size = 0.5, se =FALSE) +
facet_grid(~sex)
ggplot(data = Salaries, aes(x=yrs.service, y=salary,color = rank))+
scale_color_manual(values = c("red" , "blue","green")) +
geom_point(size = 2)
library(gridExtra)
p1 <- ggplot(data = Salaries, aes(x = rank)) + geom_bar()
p2 <- ggplot(data = Salaries , aes(x = sex)) + geom_bar()
p3 <- ggplot(data = Salaries , aes(x = yrs.since.phd , y = salary)) + geom_point()
grid.arrange(p1,p2,p3, ncol = 3)
library(ggthemes)
p1 + theme_stata()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment