logo
down
shadow

ggplot and ggsignif error on grouping variable


ggplot and ggsignif error on grouping variable

By : user2186241
Date : November 24 2020, 04:01 AM
it fixes the issue The issue is that geom_signif inherits the aesthetics define before and then looks for Gender in significant_df, which it doesn't find.
I'm not sure if that gives you a desired result, but to make the plot work you can add inherit.aes = FALSE:
code :
geom_signif(
    inherit.aes = FALSE,
    ...


Share : facebook icon twitter icon
How to sort results in ggplot according to grouping variable

How to sort results in ggplot according to grouping variable


By : user2525008
Date : March 29 2020, 07:55 AM
will be helpful for those in need You could use interaction to do that (in order to better distinguish between Man and Woman, I used fill instead of color):
code :
ggplot(df, aes(x=interaction(ID,Gender), y=Score, fill=Gender)) + 
  geom_bar(stat="identity") +
  scale_x_discrete("ID",breaks=interaction(df$ID,df$Gender),labels=df$ID) +
  theme_bw() +
  theme(axis.title = element_text(size=14,face="bold"), axis.text = element_text(size=12))
ggplot(df, aes(x=factor(ID), y=Score, fill=Gender)) + 
  geom_bar(stat="identity") +
  scale_x_discrete("ID",breaks=df$ID,labels=df$ID) +
  facet_grid(.~Gender, scales="free_x") +
  guides(fill=FALSE) + theme_bw() +
  theme(axis.title=element_text(size=14,face="bold"), axis.text=element_text(size=12),
        strip.text=element_text(size=12,face="bold"), strip.background=element_rect(fill=NA,color=NA))
Add error bars to ggplot line plot with grouping variable

Add error bars to ggplot line plot with grouping variable


By : James Frank
Date : March 29 2020, 07:55 AM
it should still fix some issue You might be looking for something like this?
(I added facet_wrap for better visibility, as the lines are all rather close to one another.)
code :
error_bars <- tidyr::spread(data, variable, value)
colnames(error_bars)[6:7] <- c("mean", "sd") # shorter variable names

ggplot(error_bars,
       aes(x = post, y = mean, color = condition, group = condition)) +
  geom_line() +
  geom_point() +
  geom_errorbar(aes(ymin = mean - sd, ymax = mean + sd)) +
  facet_wrap(~condition)
How to order a discrete variable in a scatterplot by a third grouping variable with ggplot?

How to order a discrete variable in a scatterplot by a third grouping variable with ggplot?


By : user2976480
Date : March 29 2020, 07:55 AM
this will help Minimal Reproducible Example: , With reorder:
code :
data %>% mutate(study=reorder(study, as.numeric(tool))) %>% 
  ggplot(aes(x = auc, y = study)) +  
  geom_point(aes(color = tool), size = 4)
R ggplot on-the-fly calculation by grouping variable

R ggplot on-the-fly calculation by grouping variable


By : C Ariel
Date : March 29 2020, 07:55 AM
around this issue I have added stat_apply_group() and stat_apply_panel() to the development version of my package 'ggpmisc'. It will take some time before this update makes it to CRAN as the previous update has just been accepted.
For the time being 'ggpmisc' should be installed from Bitbucket for the new stats to be available.
code :
devtools::install_bitbucket("aphalo/ggpmisc", ref = "no-debug")
library(ggplot2)
library(ggpmisc)
set.seed(123456)
df <- data.frame(X = rep(1:20,2),
                 Y = runif(40),
                 category = rep(c("A","B"), each = 20))
ggplot(df, aes(x = X, y = Y, colour = category)) +
  stat_apply_group(.fun.y = cumsum)
How to add ANOVA one-way p-value to ggplot with ggsignif

How to add ANOVA one-way p-value to ggplot with ggsignif


By : user6087772
Date : September 23 2020, 11:00 PM
To fix this issue I have the following data , The p-value of one-way anova with two group is the same as t.test.
code :
ggplot(data, aes(x = label, y = value )) + 
  geom_boxplot() + 
  geom_signif(comparison = list(c("A",  "B")), y_position = 11, test = "t.test")
Related Posts Related Posts :
  • Finding income ratio by student status
  • Sum and Count Changes per Group for each Column in R
  • Writing a Path/Route Plot as a GeoTiff in R
  • Shorter order expression in R
  • Make a function using apply, stringr, stringi, and rbind run faster
  • Using cast() or ddply() to summarise the mean for two continuous variables in one dataframe
  • How to assign ID to multiple rows based on a value in 1 column in 1 row duplicating a value in a DIFFERENT column in a d
  • apply transparent background to divide plot area based on x values using ggplot
  • pivot a data frame and exclude blank cells in r
  • Subsetting Polygons from Spatial Polygons object by slot
  • Error: Don't know how to add e2 to a plot
  • selecting values from a df based on multiple percentages from a different dataframe
  • Why does R paste more decimals than have been rounded, but only sometimes?
  • Emacs ESS indent after %>%
  • Editing data frame after reactive upload in R shiny
  • R: How to add a zero into the middle of a string
  • Write a loop to select all combination of variable values generating positive equation values in R
  • Parameterizing group_by %>% summarise
  • How to display HTML in DT header?
  • R Vectorizing Operation
  • Cystoscape node color
  • geom_tile border missing at corners
  • Geting new data into old data frame in R
  • Eigenvector values for different time periods of same network (igraph in R)
  • Write a function with default column name inputs in dplyr::mutate()
  • Why isn't string splitting after last open parenthesis?
  • blogdown - how do I specify which page a post will appear on
  • Can I span groups of categories with horizontal lines in ggplot2
  • RODBC gives proper row count but yields empty query
  • Merging two incomplete factors
  • reshaping data with time represented as spells
  • R ggplot: How to create a scatter plot with marginal box plots
  • Rcpp use outer with pmax
  • Symbolic matrix mutiplication error (Ryacas)
  • Creating columns based on total number of columns in a data frame R
  • How do I address R raster mosaic error: 'data' must be of a vector type, was 'NULL'?
  • ggplot2() plotting one variable against itself by factor?
  • Random sets with three random numbers in it (sampling random points in a cube)
  • Function to find varying strings
  • How do I post some introductory paragraphs on the main page of my blogdown site?
  • Correlations between numerous variables grouped in dplyr
  • Animating 3d object in R Markdown html with play3d
  • Suppress multiple package/library loading messages
  • R CMD REMOVE has no effect
  • repeated observations average per month
  • Count values per year and based on other column
  • aggregating elements to create groups of minimal size
  • efficient subsetting of data.table with greater-than, less-than using indices
  • Prefix/suffix column content with column names
  • R - How to use sum and group_by inside apply?
  • For Each Loop to convert into numeric values
  • How to summarise taking a random value from a categorical column?
  • Predictions in SageMaker ::: Writing Function To Split Big Data-frame Into Batches For Predictions
  • ggplot: How to keep marker colours in legend but hide text colours?
  • Removing character elements from a vector
  • Cumulative sum based on factor on R
  • expand colnames to match the last known one
  • `testthat::expect_silent()` does not seem to notice ggplot2 errors
  • Parse Factor in R
  • Exit from Command prompt after running r script
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org