Comments (9)
Hi Pauline,
thank you for filling the issue. Could you please provide a reproducible example (preferably using reprex), so that I can investigate the problem?
Best, Constantin
from ggsignif.
I get identical p-values:
library(ggplot2)
library(ggsignif)
x <- rnorm(10)
y <- rnorm(10)
t.test(x, y)
#>
#> Welch Two Sample t-test
#>
#> data: x and y
#> t = 1.1129, df = 17.016, p-value = 0.2812
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#> -0.4248211 1.3735109
#> sample estimates:
#> mean of x mean of y
#> 0.2474435 -0.2269013
df <- data.frame(condition = c(rep("x", 10), rep("y", 10)),
value = c(x, y))
ggplot(df, aes(x=condition, y=value)) +
geom_boxplot() +
ggsignif::geom_signif(comparison = list(c("x", "y")),
test = "t.test")
Created on 2019-03-27 by the reprex package (v0.2.1)
from ggsignif.
Here is my example, where I do not get the same results
from ggsignif.
sorry it didn't pass completely, let me retry
from ggsignif.
Ah, sorry. I tried to add code highlighting to your comment, but now it has disappeared!
from ggsignif.
Sorry, I'm new using reprex, so it wasn't working properly
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 3.4.4
library("ggsignif")
#> Warning: package 'ggsignif' was built under R version 3.4.4
the.data <- data.frame("number.events" = c(10,25,24,27,22,2,4,34,10,11,18,6,25,9,8,31,10,44,15), "condition"=c(3,1,1,1,1,1,2,1,1,1,1,2,1,1,1,3,3,3,1))
t.test(the.data$condition==1,the.data$condition==2)
#>
#> Welch Two Sample t-test
#>
#> data: the.data$condition == 1 and the.data$condition == 2
#> t = 4.4098, df = 31.187, p-value = 0.0001144
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#> 0.3112523 0.8466424
#> sample estimates:
#> mean of x mean of y
#> 0.6842105 0.1052632
t.test(the.data$condition==1,the.data$condition==3)
#>
#> Welch Two Sample t-test
#>
#> data: the.data$condition == 1 and the.data$condition == 3
#> t = 3.2504, df = 35.398, p-value = 0.00253
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#> 0.1779549 0.7694135
#> sample estimates:
#> mean of x mean of y
#> 0.6842105 0.2105263
t.test(the.data$condition==2,the.data$condition==3)
#>
#> Welch Two Sample t-test
#>
#> data: the.data$condition == 2 and the.data$condition == 3
#> t = -0.87519, df = 33.442, p-value = 0.3877
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#> -0.3498411 0.1393148
#> sample estimates:
#> mean of x mean of y
#> 0.1052632 0.2105263
bplot <- ggplot(the.data, aes(x=factor(condition,levels =c("1", "2", "3")), y=number.events)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"),
axis.text=element_text(size=15),
axis.title=element_text(size=17,face="bold")) +
geom_boxplot(color = c("red","blue","darkgreen")) +
labs(x="Conditions",y="Occurences") +
geom_signif(comparisons = list(c("1", "2")),
test = "t.test",
map_signif_level=FALSE,
y_position = 37)+
geom_signif(comparisons = list(c("1", "3")), #ns
test = "t.test",
map_signif_level=FALSE,
y_position = 48)+
geom_signif(comparisons = list(c("2", "3")), #ns
test = "t.test",
map_signif_level=FALSE,
y_position = 46)
bplot
Created on 2019-03-27 by the reprex package (v0.2.1)
from ggsignif.
Yes, thanks for reposting it.
I think I know what the problem is. In your t.test
you write:
t.test(the.data$condition==1,
the.data$condition==3)
and you get a very small p-value for this. But only because
print(the.data$condition==1)
#> [1] FALSE TRUE TRUE TRUE TRUE TRUE FALSE TRUE TRUE TRUE TRUE
#> [12] FALSE TRUE TRUE TRUE FALSE FALSE FALSE TRUE
print(the.data$condition==3)
#> [1] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [12] FALSE FALSE FALSE FALSE TRUE TRUE TRUE FALSE
which are converted to zeros and ones.
What you actually want to do is:
t.test(the.data[the.data$condition==1, "number.events"],
the.data[the.data$condition==3, "number.events"])
#>
#> Welch Two Sample t-test
#>
#> data: the.data[the.data$condition == 1, "number.events"] and the.data[the.data$condition == 3, "number.events"]
#> t = -0.69142, df = 3.5927, p-value = 0.5314
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#> -31.50988 19.39450
#> sample estimates:
#> mean of x mean of y
#> 17.69231 23.75000
which corresponds to the p-value my package outputs.
Best, Constantin
from ggsignif.
Ah ! Yes of course ! Sorry for my mistake and thank you for the help
Best,
Pauline
from ggsignif.
No problem, you had me worried there for a second. But I am glad that we could easily resolve the issue.
Best, Constantin
from ggsignif.
Related Issues (20)
- Error using facet_wrap & geom_signif : "Replacement has X rows..." HOT 2
- Customizing geom_signif with facet grid HOT 3
- Significance brackets HOT 1
- Figure out where the `WARNING`s and `NOTE`s in `R CMD check` are coming from HOT 1
- Manual vertical brackets do not work: "arguments imply differing number of rows" HOT 1
- Warning message: Ignoring unknown aesthetics: xmin, xmax, annotations, y_position HOT 3
- adding scale_y_log10 changes y-axis to a weird range
- geom_signif does not plot comparison on the facetted plot with free x scale HOT 2
- Where can we find the significance level in the ggplot object slots? HOT 1
- Rename default branch from `master` to `main` HOT 3
- CRAN release 0.6.4 HOT 3
- Correcting for multiple testing when using geom_signif HOT 5
- Feature request - add more distance between comparisons and data HOT 4
- geom_signif - all comparisons dissappear when one comparison has missings HOT 2
- Significance stars are misaligned when using "NS" as well
- ggsignif results don't match with anova significance HOT 1
- Use cross symbol when p <.10?
- what are * , ** , *** correspond if specific values by user is not given? HOT 1
- How do I hide the no significant (NS) comparisons?
- Adding significance bar on coupled boxplots
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggsignif.