multiple box plot with posthoc test result as letters

@technocrat,

I have added data detail with str command, it says this is also a data frame after reading the file by read.table in R.

Many thanks,

multcompBoxplot(SampleType ~ Cd, data = bpdata[, c(1, 6)])

Cd is the seventh column, not the sixth. Use Cd or change data argument to

multcompBoxplot(SampleType ~ Cd, data = bpdata[, c(1, 7)])

Thanks, but again some error;
code;

suppressPackageStartupMessages({
  library(multcompView)
})

bpdata <- read.table("Box.plot.chemical.txt", sep="\t", header=TRUE, row.names= NULL)
str(bpdata)


pdf("test2.plot.pdf", width = 10, height = 8)

multcompBoxplot(SampleType ~ Cd, data = bpdata[, c(1, 7)])
dev.off();
Error in oldClass(stats) <- cl :
  adding class "factor" to an invalid object
Calls: multcompBoxplot ... boxplot -> boxplot.formula -> boxplot -> boxplot.defa                                                                                        ult
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Execution halted

Many thanks

Look, it's very hard to eyeball this stuff. See the FAQ: How to do a minimal reproducible example reprex for beginners for how to provide representative data that can be cut and pasted.

@technocrat,

I have pasted here reproducible code from a file;

SampleType Bacteria Fe P Ca
D_M_1Chemical 7,00,000 1,40,67,895 3,80,000 69,000
D_M_2Farm 3,16,680 93,11,160 2,50,000 26,000
D_M_3ChemicalFarm 3,13,010 84,22,355 4,60,000 30,000
D_M_1Chemical 3,74,535 92,59,900 2,80,000 33,000
D_M_2Farm 3,70,000 1,69,52,360 3,20,000 72,000
D_M_3ChemicalFarm 4,62,480 1,05,26,390 3,60,000 64,000
D_M_1Chemical 3,74,860 83,78,655 2,90,000 49,000
D_M_2Farm 3,81,900 94,68,550 3,90,000 73,000
D_M_3ChemicalFarm 2,00,000 57,83,980 4,40,000 61,000
D_M_1Chemical 2,24,125 80,77,105 6,00,000 89,000
D_M_2Farm 1,90,810 81,54,005 6,00,000 61,000
D_M_3ChemicalFarm 1,77,050 83,33,120 6,00,000 69,000
D_M_1Chemical 2,70,000 52,77,265 2,00,000 34,000
D_M_2Farm 4,03,380 92,37,105 4,90,000 80,000
D_M_3ChemicalFarm 3,72,530 1,06,24,735 4,80,000 57,000
D_M_1Chemical 2,61,215 62,28,160 3,40,000 37,000
D_M_2Farm 7,50,000 1,62,58,720 4,40,000 80,000
D_M_3ChemicalFarm 6,33,895 1,09,52,305 3,80,000 54,000
D_M_1Chemical 5,83,367 1,03,83,383 3,10,000 53,000
D_M_2Farm 6,53,945 1,01,48,210 3,80,000 48,000
D_M_3ChemicalFarm 5,70,000 1,10,00,000 1,80,000 1,70,000
D_M_1Chemical 5,20,000 2,70,00,000 1,30,000 1,90,000
D_M_2Farm 5,40,000 2,10,00,000 2,50,000 1,40,000
D_M_3ChemicalFarm 4,70,000 1,00,00,000 1,10,000 70,000
D_M_1Chemical 6,40,000 1,30,00,000 1,70,000 90,000
D_M_2Farm 7,70,000 1,70,00,000 2,30,000 1,20,000
D_M_3ChemicalFarm 7,20,000 1,50,00,000 1,20,000 1,70,000
D_B_1Chemical 6,20,000 1,20,00,000 98,000 74,000
D_B_2Farm 9,40,000 2,95,82,000 1,90,000 46,000
D_B_3ChemicalFarm 9,52,400 2,71,86,525 2,10,000 67,000
D_B_1Chemical 5,03,300 1,11,40,225 85,000 24,000

So the first column is Sampletype and others are variable.

Many thanks,

Thanks. I'll look at it, but this is what reproducible code looks like (cut-and-paste) using dput(your_data.frame)

dat <- structure(list(
  SampleType =
    c("D_M_1Chemical", "D_M_2Farm", "D_M_3ChemicalFarm", "D_M_1Chemical", "D_M_2Farm", "D_M_3ChemicalFarm", "D_M_1Chemical", "D_M_2Farm", "D_M_3ChemicalFarm", "D_M_1Chemical", "D_M_2Farm", "D_M_3ChemicalFarm", "D_M_1Chemical", "D_M_2Farm", "D_M_3ChemicalFarm", "D_M_1Chemical", "D_M_2Farm", "D_M_3ChemicalFarm", "D_M_1Chemical", "D_M_2Farm", "D_M_3ChemicalFarm", "D_M_1Chemical", "D_M_2Farm", "D_M_3ChemicalFarm", "D_M_1Chemical", "D_M_2Farm", "D_M_3ChemicalFarm", "D_B_1Chemical", "D_B_2Farm", "D_B_3ChemicalFarm", "D_B_1Chemical"),
  Bacteria =
    c(7e+05, 316680, 313010, 374535, 370000, 462480, 374860, 381900, 2e+05, 224125, 190810, 177050, 270000, 403380, 372530, 261215, 750000, 633895, 583367, 653945, 570000, 520000, 540000, 470000, 640000, 770000, 720000, 620000, 940000, 952400, 503300),
  Fe =
    c(14067895, 9311160, 8422355, 9259900, 16952360, 10526390, 8378655, 9468550, 5783980, 8077105, 8154005, 8333120, 5277265, 9237105, 10624735, 6228160, 16258720, 10952305, 10383383, 10148210, 1.1e+07, 2.7e+07, 2.1e+07, 1e+07, 1.3e+07, 1.7e+07, 1.5e+07, 1.2e+07, 29582000, 27186525, 11140225),
  P =
    c(380000, 250000, 460000, 280000, 320000, 360000, 290000, 390000, 440000, 6e+05, 6e+05, 6e+05, 2e+05, 490000, 480000, 340000, 440000, 380000, 310000, 380000, 180000, 130000, 250000, 110000, 170000, 230000, 120000, 98000, 190000, 210000, 85000),
  Ca =
    c(69000, 26000, 30000, 33000, 72000, 64000, 49000, 73000, 61000, 89000, 61000, 69000, 34000, 80000, 57000, 37000, 80000, 54000, 53000, 48000, 170000, 190000, 140000, 70000, 90000, 120000, 170000, 74000, 46000, 67000, 24000)),
  class =
    c("spec_tbl_df", "tbl_df", "tbl", "data.frame"),
  row.names =
    c(NA, -31L), spec = structure(list(cols = list( SampleType = structure(list(),
  class =
    c("collector_character", "collector")), Bacteria = structure(list(),
  class =
    c("collector_double", "collector")), Fe = structure(list(),
  class =
    c("collector_double", "collector")), P = structure(list(),
  class =
    c("collector_double", "collector")), Ca = structure(list(),
  class =
    c("collector_double", "collector"))), default = structure(list(),
  class =
    c("collector_guess", "collector")), skip = 1L),
  class = "col_spec"))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.