ggally

Create a ggplot2 survival curve with censored table

我怕爱的太早我们不能终老 提交于 2019-12-02 11:24:41
I am trying to create a Kaplan-Meier plot with 95% confidence bands plus having the censored data in a table beneath it. I can create the plot, but not the table. I get the error message: Error in grid.draw(both) : object 'both' not found. library(survival) library(ggplot2) library(GGally) library(gtable) data(lung) sf.sex <- survfit(Surv(time, status) ~ sex, data = lung) pl.sex <- ggsurv(sf.sex) + geom_ribbon(aes(ymin=low,ymax=up,fill=group),alpha=0.3) + guides(fill=guide_legend("sex")) pl.sex tbl <- ggplot(df_nums, aes(x = Time, y = factor(variable), colour = variable,+ label=value)) + geom

Rounding digits in ggpairs

僤鯓⒐⒋嵵緔 提交于 2019-12-01 14:46:02
Is it possible to round the correlations digits in ggpairs to, for example 2 digits somehow? library(GGally) ggpairs(iris, columns = 1:4, mapping = ggplot2::aes(col = Species)) Here is a modified version of ggally_cor . I added the sgnf parameter, indicating the number of significant digits. mycor <- function(data, mapping, alignPercent = 0.6, method = "pearson", use = "complete.obs", corAlignPercent = NULL, corMethod = NULL, corUse = NULL, sgnf=3, ...) { if (!is.null(corAlignPercent)) { stop("'corAlignPercent' is deprecated. Please use argument 'alignPercent'") } if (!is.null(corMethod)) {

Controlling color in ggparcoord (from GGally package)

社会主义新天地 提交于 2019-12-01 12:42:11
I am trying to hard-code the desired line color for a particular ggparcoord plot. For instance, when I create my ggparcoord plot below: library(GGally) x = data.frame(a=runif(100,0,1),b=runif(100,0,1),c=runif(100,0,1),d=runif(100,0,1)) x$cluster = "green" x$cluster2 = factor(x$cluster) ggparcoord(x, columns=1:4, groupColumn=5, scale="globalminmax", alphaLines = 0.99) + xlab("Sample") + ylab("log(Count)") Even though I try to specify a color of "green", I get a pink color. How can I control the color of the lines in ggparcoord? (By the way, I want all lines the same color as I specify). You

Rounding digits in ggpairs

强颜欢笑 提交于 2019-12-01 12:08:34
问题 Is it possible to round the correlations digits in ggpairs to, for example 2 digits somehow? library(GGally) ggpairs(iris, columns = 1:4, mapping = ggplot2::aes(col = Species)) 回答1: Here is a modified version of ggally_cor . I added the sgnf parameter, indicating the number of significant digits. mycor <- function(data, mapping, alignPercent = 0.6, method = "pearson", use = "complete.obs", corAlignPercent = NULL, corMethod = NULL, corUse = NULL, sgnf=3, ...) { if (!is.null(corAlignPercent)) {

GGpairs, correlation values are not aligned

烈酒焚心 提交于 2019-12-01 11:16:06
I am trying to create a correlation matrix using GGpairs, the scatterplots are coloured by group (reg or irreg). The correlation values plotted on the upper corner are not aligned, as you see in the image here the Cor, reg and irreg values are not aligned. The code I use is this: ggpairs(data=dat4, columns=1:5, title="correlation matrix", mapping= aes(colour = irregular), lower = list( continuous = "smooth", combo = "facetdensity", mapping = aes(color = irregular))) The data is here: replicatable data Any suggestion? Thank you thank you! Chuck This seems to work: ggpairs(data=dat4, columns=1:5

GGpairs, correlation values are not aligned

删除回忆录丶 提交于 2019-12-01 09:00:43
问题 I am trying to create a correlation matrix using GGpairs, the scatterplots are coloured by group (reg or irreg). The correlation values plotted on the upper corner are not aligned, as you see in the image here the Cor, reg and irreg values are not aligned. The code I use is this: ggpairs(data=dat4, columns=1:5, title="correlation matrix", mapping= aes(colour = irregular), lower = list( continuous = "smooth", combo = "facetdensity", mapping = aes(color = irregular))) The data is here:

ggpairs plot with heatmap of correlation values

夙愿已清 提交于 2019-12-01 06:09:39
My question is twofold; I have a ggpairs plot with the default upper = list(continuous = cor) and I would like to colour the tiles by correlation values (exactly like what ggcorr does). I have this: I would like the correlation values of the plot above to be coloured like this: library(GGally) sample_df <- data.frame(replicate(7,sample(0:5000,100))) colnames(sample_df) <- c("KUM", "MHP", "WEB", "OSH", "JAC", "WSW", "gaugings") ggpairs(sample_df, lower = list(continuous = "smooth")) ggcorr(sample_df, label = TRUE, label_round = 2) I had a brief go at trying to use upper = list(continuous = wrap

How to set same scales across different facets with ggpairs()

本秂侑毒 提交于 2019-12-01 03:37:24
I have the following dataset and codes to construct the 2d density contour plot for each pair of variables in the data frame. My question is whether there is a way in ggpairs() to make sure that the scales are the same for different pairs of variables like the same scale for different facets in ggplot2. For example, I would like the x scale and y scale are all from [-1, 1] for each of the picture. Thanks in advance! The plot looks like library(GGally) ggpairs(df,upper = list(continuous = "density"), lower = list(combo = "facetdensity")) #the dataset looks like print(df) x y z w 1 0.49916998 -0

How to change the color palette for GGally::ggpairs?

痞子三分冷 提交于 2019-12-01 02:35:49
问题 This is the same question as in User defined colour palette in R and ggpairs or is there a way to change the color palette for GGally::ggpairs using ggplot? only that the solutions there don't work anymore. I also want to change the color palette, but is there a way to change the color palette for GGally::ggpairs using ggplot? does not work anymore. What to do? MWE: library(GGally) library(ggplot2) data(diamonds, package="ggplot2") diamonds.samp <- diamonds[sample(1:dim(diamonds)[1],200),]

incorporate standalone legend in ggpairs (take 2)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 02:00:35
问题 tl;dr can't get a standalone legend (describing common colours across the whole plot) in ggpairs to my satisfaction. Sorry for length. I'm trying to draw a (lower-triangular) pairs plot using GGally::ggpairs (an extension package for drawing various kinds of plot matrices with ggplot2 ). This is essentially the same question as How to add an external legend to ggpairs()? , but I'm not satisfied with the answer to that question aesthetically, so I'm posting this as an extension (if suggested