Coder Social home page Coder Social logo

ggerr's Introduction

Using ggerr

Thomas Poulsen, 2019-10-20

The ggerr package makes it easier to add error-bars to pplots.

Adding errorbars of +/- one standard deviation in each group is done like this:

library(ggplot2)
library(ggerr)

ggplot(iris, aes(x = Petal.Length, y = Petal.Width, color = Species)) + geom_point() + stat_err() + stat_err(geom="point")

The second call to stat_err() with geom "point" is to add the point at the mean.

The stat_err() detaults to the geom "errorbar", so the width of the whiskers are controlled through that:

ggplot(iris, aes(x = Petal.Length, y = Petal.Width, color = Species)) + geom_point() + stat_err(width=.1) + stat_err(geom="point")

Horizontal errorbars are obtained by the geom "errorbarh". The stat_err() knows about standard deviation and standard error of the mean. They are selected by the spread parameter. It is possible to multiply the errorbars by a factor, using the mult parameter.

The grouping does not need to be coltrolled by the color aestetics, it can also be done through an explicit group aestetics.

As an example, we add vertical and horizontal errorbars of two times the standard error of the mean:

ggplot(iris, aes(x = Petal.Length, y = Petal.Width, group = Species)) + geom_point(aes(color=Species)) + stat_err(spread = "se", mult = 2, width=.1) + stat_err(geom="point") + stat_err(spread = "se", mult = 2, geom = "errorbarh", height = .1)

Installation

Install the package using devtools:

devtools::install_github("tp2750/ggerr")

ggerr's People

Contributors

tp2750 avatar

Watchers

 avatar

Forkers

pang-hd

ggerr's Issues

Add geom for easier errorbars

We currently need individual calls to stat_err() to set vertical and horizontal errorbars.
It would be better to have a geom, that could do both at the same time.

Perhaps call it "geom_crosshair" ?

It would be good, if it can have the whiskers scale relative to the axes, so they are always et 5% of the length of the corresponding axes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.