Last active
February 9, 2017 02:52
-
-
Save jspaezp/f0072ea4620ee1aef750d8ff33011e19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generacion de los datos | |
x <- runif(20) + 1 | |
y <- rep(c('a','b', 'c', 'd'), 5) | |
z <- rep(c('FACTOR 1','FACTOR 2'), 5) | |
# hacer el DF | |
my_data <- data.frame(x1 = sample(x), y1 = y, z1 = z) | |
# Cargar los paquetes | |
require(ggplot2) | |
require(dplyr) | |
# Este grafico muestra las lineas en el medio de la barra | |
my_data | |
g <- ggplot(my_data, aes(x = y1, y = x1, fill = z1)) | |
g <- g + geom_bar(stat = 'identity', position = position_dodge(), colour = 'black') | |
g | |
my_data2 <- my_data %>% group_by(y1,z1) %>% summarise(x1 = mean(x1)) | |
my_data2 | |
# Este grafico muestra como dejan de aparecer cuando se tiene solo la media | |
g <- ggplot(my_data2, aes(x = y1, y = x1, fill = z1, group = interaction(y1,z1))) | |
g <- g + geom_bar(stat = 'identity', position = position_dodge(), colour = 'black') | |
g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment