background preloader

R-project

Facebook Twitter

Index. ggplot2 0.9.3. Geoms Geoms, short for geometric objects, describe the type of plot you will produce. geom_abline(geom_hline, geom_vline) Lines: horizontal, vertical, and specified by slope and intercept.

Index. ggplot2 0.9.3

Geom_bar(stat_count) Bars, rectangles with bases on x-axis geom_bin2d(stat_bin2d, stat_bin_2d)Add heatmap of 2d bin counts. Geom_blankBlank, draws nothing. Geom_boxplot(stat_boxplot) Box and whiskers plot. Statistics It's often useful to transform your data before plotting, and that's what statistical transformations do. stat_ecdf Empirical Cumulative Density Function stat_ellipsePlot data ellipses. Scales Scales control the mapping between data and aesthetics. expand_limitsExpand the plot limits with data. Coordinate systems Coordinate systems adjust the mapping from coordinates to the 2d plane of the computer screen. coord_cartesian Cartesian coordinates.

Faceting Facets display subsets of the dataset in different panels. facet_grid Lay out panels in a grid. Position adjustments Data Annotation Themes. Graphs. My book about data visualization in R is available!

Graphs

The book covers many of the same topics as the Graphs and Data Manipulation sections of this website, but it goes into more depth and covers a broader range of techniques. You can preview it at Google Books. Purchase it from Amazon, or direct from O'Reilly. There are many ways of making graphs in R, each with its advantages and disadvantages. Graphs with ggplot2 Miscellaneous Output to a file - PDF, PNG, TIFF, SVG Shapes and line types - Set the shape of points and patterns used in lines. Basic graphs with standard graphics Other interesting graphs Correlation matrix ggplot2 online documentation.

R Tutorials. Learning R. John Fox's Home Page. Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 "He who loves practice without theory is like the sailor who boards ship without a rudder and compass and never knows where he may be cast. " -- Leonardo da Vinci, 1452-1519 McMaster Course Information: Sociology 3H6 (2011-2012): Research Techniques and Data Analysis Sociology 6Z3 (Fall 2007): Quantitative Methods in Sociology Sociology 740 (Winter 2013): Applications of Quantitative Methods Sociology 761 (Fall 2006): Statistical Applications in Social Research Selected Short Courses, Lectures, Workshops, and Tutorials: Tutorial Lectures on R: structural equation modeling, effect displays, extending the R Commander by plug-ins (November 2012, Institute of Statistical Mathematics, Tokyo) R Statistical Computing Environment: The R Project, data analysis in R, statistical models in R, structural equation modeling, the R Commander, MANOVA and repeated-measures ANOVA (October 2012, University of Barcelona)

Quick-R: Home Page. R-project. Axes and Text. Many high level plotting functions (plot, hist, boxplot, etc.) allow you to include axis and text options (as well as other graphical paramters).

Axes and Text

For example # Specify axis options within plot() plot(x, y, main="title", sub="subtitle", xlab="X-axis label", ylab="y-axix label", xlim=c(xmin, xmax), ylim=c(ymin, ymax)) For finer control or for modularization, you can use the functions described below. Titles Use the title( ) function to add labels to a plot. title(main="main title", sub="sub-title", xlab="x-axis label", ylab="y-axis label") Many other graphical parameters (such as text size, font, rotation, and color) can also be specified in the title( ) function. # Add a red title and a blue subtitle.

Text Annotations Text can be added to graphs using the text( ) and mtext( ) functions. text( ) places text within the graph while mtext( ) places text in one of the four margins. text(location, "text to place", pos, ...) mtext("text to place", side, line=n, ...) Common options are described below.