-
A clever use of geom smooth position =…
message d'accroche site de rencontre A clever use of geom_smooth(position = ‘jitter’) for plots looking like hand-written. test.dframe
-
Change the order of discrete axis Generate a…
http://mt-creations.fr/wp-json/oembed/1.0/embed?url=http://mt-creations.fr/portfolio/renovation-dun-appartement-a-saint-etienne-3/ Change the order of discrete axis. Generate a factor with reversed levels or use a new ggplot2 option. Examples. df$X1 = with(df, factor(X1, levels = rev(levels(X1)))) http://stackoverflow.com/questions/7418191/sorting-dotplot-factor-axis-in-ggplot Reverse the order of a discrete-valued axis Get the levels of the factor flevels
-
Slopegraph in R Slopegraph shows the change of…
Slopegraph in R. Slopegraph shows the change of the quantity or rank. Beautiful slopegraph example. http://www.drewconway.com/zia/ Theory of slopegraph. http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0003nk An R and ggplot2 code example of slopegraph https://github.com/leondutoit/slopegraph/blob/master/slopegraph. R Example code. Generate sample data a
-
scatter plot equivalent to pairs by ggplot http…
scatter plot equivalent to pairs() by ggplot. http://stackoverflow.com/questions/3735286/pairs-equivalent-in-ggplot2 Hadley recommends using the GGally package instead. It has a function, ggpairs that is a vastly improved pairs plot (lets you use non-continuous variables in your data frames). It plots different plots in each square, depending on the variable types:
-
Multiple histograms in a plot using ggplot2 ggplot…
Multiple histograms in a plot using ggplot2. ggplot(test.melt, aes(x = value, fill = sample)) + geom_histogram(alpha = 0.3, position = ‘identity’, aes(y = ..density..)) + geom_density(alpha = 0.3, position = ‘identity’) Be careful. The default value for the position parameter is different the histogram and density plot. So set the parameter explicitly. Identity: overlap the…
-
Change the label of legend not by changing…
Change the label of legend not by changing the data. # data grp
-
Customize the color order and label of the…
Customize the color, order and label of the legend in ggplot2 Use scale_colour_manual() scale_colour_manual(values = c(“red”, “blue”), breaks = c(“S2”, “S1”), labels = c(“sample1”, “sample2”)) http://had.co.nz/ggplot2/scale_manual.html
-
ggplot2 opts list https github com hadley ggplot2…
ggplot2 opts list https://github.com/hadley/ggplot2/wiki/%2Bopts%28%29-List
-
Sometimes R gives the error message Error in…
Sometimes R gives the error message. Error in X11(d$display, d$width, d$height, d$pointsize, d$gamma, d$colortype, : unable to start device X11cairo Here is the fix. Sys.setenv(“DISPLAY”=”:0.0″)
-
How to use eval Here is an example…
How to use eval()? Here is an example. test.dframe <- data.frame(x = 1:10, y = rnorm(10)) addSmooth <- function(data, smooth = TRUE) { require(ggplot2) p <- "ggplot(data = data, aes(x = x, y = y))" p.line <- "geom_line()" p.smooth <- "stat_smooth()" if (smooth == TRUE) { p.all <- paste(p, p.line, p.smooth, sep = " +…