Adding p-value to box plot
1
0
Entering edit mode
5.5 years ago
khn ▴ 140

I want to add p-value for box plots for independent two groups.

But the error said,,,

> p + stat_compare_means()
Don't know how to automatically pick scale for object of type quosure/formula. Defaulting to continuous.
Don't know how to automatically pick scale for object of type quosure/formula. Defaulting to continuous.
Error in validDetails.text(x) : 
  'pairlist' object cannot be coerced to type 'double'

Do you know how to resolve this? Maybe box plot does not show means, but I want to show p-value based on means?

Thank you in advance!!

R • 4.5k views
ADD COMMENT
0
Entering edit mode

Share an excerpt of the dataset and the code you are using.

ADD REPLY
0
Entering edit mode

How is your datatable ?

I used this some weeks ago:

ggplot(mean_expressed, aes(x = mean_expressed$variable, y = mean_expressed$value)) + 
  geom_boxplot(outlier.colour='black') + stat_compare_means(aes(group = mean_expressed$variable)

mean_expressed$variable is a qualitative variable that refers to groups to compare, and mean_expressed$value for the values

boxplot

ADD REPLY
0
Entering edit mode

Please use the formatting bar (especially the code option) to present your post better. You can use backticks for inline code (`text` becomes text), or select a chunk of text and use the highlighted button to format it as a code block. I've done it for you this time.
code_formatting

ADD REPLY
0
Entering edit mode

Try this.

stat_compare_means(aes(group = Data), label = "p.format")
ADD REPLY
0
Entering edit mode

Please use the formatting bar (especially the code option) to present your post better. You can use backticks for inline code (`text` becomes text), or select a chunk of text and use the highlighted button to format it as a code block. I've done it for you this time.
code_formatting

ADD REPLY
0
Entering edit mode
5.5 years ago
khn ▴ 140

Thank you so much for everybody! The codes you provided me did not work again, so I tried as below, which worked actually.

my_comparisons <- list( c("1", "2"), c("1", "3"), c("1", "4"),c("1", "5"), c("1", "7"), c("2", "3"), c("2", "4"), c("2", "5"), c("2", "7"), c("3", "4"), c("3", "5"), c("3", "7"), c("4", "5"), c("4", "7"), c("5", "7") )

ggboxplot(x, x = "B", y = "A", + color = "B", palette = "jco")+ + stat_compare_means(comparisons = my_comparisons)

Though this did not show the name of analysis (Kruscal Wallis) on the plot.

Thank you!!

ADD COMMENT

Login before adding your answer.

Traffic: 1490 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6