background preloader

R PLOTS

Facebook Twitter

Getting Genetics Done: R: single plot with two different y-axes. I forgot where I originally found the code to do this, but I recently had to dig it out again to remind myself how to draw two different y axes on the same plot to show the values of two different features of the data.

Getting Genetics Done: R: single plot with two different y-axes

This is somewhat distinct from the typical use case of aesthetic mappings in ggplot2 where I want to have different lines/points/colors/etc. for the same feature across multiple subsets of data. For example, I was recently poking around with some data examining enrichment of a particular set of genes using a hypergeometric test as I was fiddling around with other parameters that included more genes in the selection (i.e., in the classic example, the number of balls drawn from some hypothetical urn). I wanted to show the -log10(p-value) on one axis and some other value (e.g., “n”) on the same plot, using a different axis on the right side of the plot. Here’s how to do it. First, generate some data: Now, draw the second plot on top of the first using the par(new=T) call. Cascading style sheets for R plots (via the Rcssplot package) This post is contributed by Tomasz Konopka.

Cascading style sheets for R plots (via the Rcssplot package)

Comments are welcome. tomasz@rcssplot.org One of the great features of R is its capable graphics framework. In principle, the framework allows us to customize all aspects of the visual presentation of data. In practice, however, customization is rather tedious. For example, R’s own boxplot function has 17 custom arguments, not counting ...; stripchart has 20. Several impressive frameworks already exist to help with visualization (e.g. ggplot2, plot.ly, etc.) In practice, we would start using Rcssplot by writing custom settings into a css file. In the R environment, we would parse these css definitions into an R object, library("Rcssplot") foo.styles <- Rcss("foo.styles.Rcss") Assuming that we have a custom plot function styledPlot, we would then create two visualizations of the same data object like this styledPlot(data, Rcss=foo.styles, Rcssclass="foo")styledPlot(data, Rcss=foo.styles, Rcssclass="bar") Related.

3D

Too Many Users. SjPlot R-package. SjPlot has been released on CRAN!

sjPlot R-package

You can install the package and its dependencies using install.packages("sjPlot")! Description Collection of several plotting and table output functions for data visualization. Results of several statistical analyses (that are commonly used in social sciences) can be visualized using this package, including simple and cross tabulated frequencies, histograms, box plots, (generalized) linear models (forest plots), PCA, correlations, cluster analyses, scatter plots etc.

Furthermore, this package contains some tools that are useful when carrying out data analysis or interpreting data (especially intended for people coming from SPSS and who are new to R). For further details, please refer this blog post… Detailed examples Detailed examples for the functions are published on RPubs. Downloads and Installation Downloads Download PDF manual and source from CRAN. Installation Use install.packages("sjPlot") to install sjPlot-package from CRAN. RPubs documentation.

Categorical

Basic Plots. Machine Learning. PCA - CA - FA - MDS. Clustering. Association Rule Mining. Plotting Systems. Color Palettes. Network graphs. Time Series. Timeline. The timeline package provides a function to create timeline figures in a style similar to Preceden. install.packages('timeline', repos=' require(timeline) data(ww2) timeline(ww2, ww2.events, event.spots=2, event.label='', event.above=FALSE) Shiny App The ww2 demo (type demo(ww2) at the R console to start) provides many variations of the timeline figure.

timeline

There is also a Shiny app to explore some of the parameters to the timeline function. timelineShinyDemo() Or try the Shiny App from the RStudio Server at Development Version Install the latest development version using devtools:

Maps/GIS - Demographics

Heatmaps. Trees. Διάφορα. GLM related.