DeliberatePractice - ggplot2
.Purpose ggplot2 examples
It has been almost 2 months since I have done any ggplot2 code. Let me engage in deliberate practice.
> library(ggplot2) |
> z <- data.frame(x = rep(c("a", "b"), 50))
> p <- ggplot(z, aes(x = x, fill = factor(x)))
> q <- p + geom_bar()
> print(q) |

> z <- data.frame(x = rep(c("a", "b"), 50))
> p <- ggplot(z, aes(x = x, fill = factor(x)))
> q <- p + geom_bar() + scale_fill_brewer("Set1")
> print(q) |

> z <- data.frame(y = rnorm(100), x = rep(c("a", "b"), 50))
> p <- ggplot(z, aes(x = x, fill = factor(x)))
> q <- p + geom_bar() + scale_fill_brewer("Set1")
> print(q + coord_flip()) |

> z <- data.frame(y = rnorm(100), x = rep(c(letters[1:10]), 10))
> p <- ggplot(z, aes(x = x, fill = factor(x)))
> q <- p + geom_bar(fill = "white", colour = "black") + xlab("Vin") +
+ opts(title = "Vinay")
> print(q + scale_y_continuous("AY") + coord_flip()) |

> z <- data.frame(y = rnorm(100), x = rep(c(letters[1:10]), 10))
> p <- ggplot(z, aes(x = x, fill = factor(x)))
> q <- p + geom_bar(colour = "black") + xlab("Vin") + opts(title = "Vinay")
> print(q + scale_y_continuous("AY") + coord_flip()) |

> z <- data.frame(y = rnorm(100), x = rep(c(letters[1:10]), 10))
> p <- ggplot(z, aes(x = x, fill = factor(x)))
> q <- p + geom_bar(colour = "black") + xlab("Vin") + opts(title = "Vinay")
> print(q + scale_y_continuous("AY") + coord_flip()) |

> p <- ggplot(diamonds, aes(color, fill = cut)) + geom_bar() + + coord_flip() > print(p) |

> z <- data.frame(x = rnorm(100), y = rnorm(100)) > p <- ggplot(z, aes(x = x, y = y)) > q <- p + geom_point() > print(q + geom_abline()) |

> z <- data.frame(x = rnorm(100), y = rnorm(100)) > p <- ggplot(z, aes(x = x, y = y)) > q <- p + geom_point() > print(q + geom_abline(intercept = -1, slope = 0.76, colour = "blue", + lwd = 3)) |

> z <- data.frame(x = rnorm(100), y = rnorm(100)) > p <- ggplot(z, aes(x = x, y = y)) > q <- p + geom_point() > print(q + geom_abline(intercept = -1, slope = 0.76, colour = "blue", + size = 1)) |
