0

I am having some issues plotting this data. I try to replicate the code in enter link description here to process the data.

Treatment   TIME    N   len sd  se
1   M1  4   44,025  2,35990819  1,179954095
1   M1  4   43,45   2,653927907 1,326963953
1   M1  4   39,825  2,681262141 1,34063107
1   M1  4   43,975  5,341894171 2,670947085
1   M1  4   41,375  3,096637962 1,548318981
1   M1  4   43,425  2,547384279 1,27369214
1   M1  4   39,45   2,598076211 1,299038106
1   M1  4   41,05   3,511409973 1,755704987
1   M1  4   40,925  1,77270979  0,886354895
1   M1  4   40,075  3,237668915 1,618834457
1   M1  4   42,375  2,758471799 1,3792359
2   M1  4   40,975  4,560975773 2,280487886
2   M1  4   40,55   3,660145717 1,830072858
2   M1  4   36,975  3,358943286 1,679471643
2   M1  4   43,175  1,64797856  0,82398928
2   M1  4   36,45   5,453744891 2,726872445
2   M1  4   41,2    2,246478726 1,123239363
2   M1  4   42,7    4,48924641  2,244623205
2   M1  4   39,5    2,759226945 1,379613472
2   M1  4   44,375  6,335810919 3,167905459
2   M1  4   42,75   1,721433511 0,860716756
2   M1  4   40,85   1,707825128 0,853912564
3   M1  4   45,975  0,699404509 0,349702254
3   M1  4   44,2    3,03644529  1,518222645
3   M1  4   42,6    4,429446918 2,214723459
3   M1  4   45,55   5,269092268 2,634546134
3   M1  4   46,525  2,022168803 1,011084401
3   M1  4   45,675  3,597568623 1,798784312
3   M1  4   47,075  2,46221445  1,231107225
3   M1  4   47,3    0,783156008 0,391578004
3   M1  4   42,025  2,639917928 1,319958964
3   M1  4   49,05   5,382997926 2,691498963
3   M1  4   48,25   4,591659105 2,295829552
1   M2  4   216,5   5,066228051 2,533114026
1   M2  4   205,75  4,991659711 2,495829855
1   M2  4   210,75  11,8988795  5,94943975
1   M2  4   204,75  23,41473895 11,70736947
1   M2  4   198,75  6,396613687 3,198306844
1   M2  4   219,75  8,732124598 4,366062299
1   M2  4   195,75  16,56049516 8,280247581
1   M2  4   219,75  7,719024118 3,859512059
1   M2  4   197,5   5,259911279 2,62995564
1   M2  4   216,25  8,995369179 4,49768459
1   M2  4   212     12,4365054  6,218252702
2   M2  4   210,25  7,041543391 3,520771696
2   M2  4   214,25  16,31716887 8,158584436
2   M2  4   208,75  9,708243919 4,85412196
2   M2  4   220,75  16,17353806 8,086769029
2   M2  4   218     30,62678566 15,31339283
2   M2  4   234     40,02499219 20,0124961
2   M2  4   217,5   5,567764363 2,783882181
2   M2  4   214,25  12,28481447 6,142407237
2   M2  4   207     13,6381817  6,819090848
2   M2  4   210,25  8,578072822 4,289036411
2   M2  4   202,75  11,52894907 5,764474535
3   M2  4   98,75   19,92276755 9,961383773
3   M2  4   101,25  10,04572878 5,022864389
3   M2  4   96,75   14,43086969 7,215434845
3   M2  4   110,5   18,06469854 9,03234927
3   M2  4   102,25  4,031128874 2,015564437
3   M2  4   109     20,54263858 10,27131929
3   M2  4   114     14,49137675 7,245688373
3   M2  4   116,25  12,71154331 6,355771655
3   M2  4   90,75   61,74881915 30,87440958
3   M2  4   123,5   26,78930135 13,39465067
3   M2  4   132,75  27,54844218 13,77422109
1   M3  4   249,75  26,06881918 13,03440959
1   M3  4   268,75  21,8384218  10,9192109
1   M3  4   241,25  27,80137886 13,90068943
1   M3  4   232,25  26,107151   13,0535755
1   M3  4   271,5   20,63169083 10,31584542
1   M3  4   277,25  26,77529956 13,38764978
1   M3  4   242     12,75408431 6,377042157
1   M3  4   260     19,4422221  9,721111048
1   M3  4   256,25  23,8100119  11,90500595
1   M3  4   254     4,898979486 2,449489743
1   M3  4   250,25  13,72042273 6,860211367
2   M3  4   256,75  16,58061117 8,290305583
2   M3  4   264,5   26,71454036 13,35727018
2   M3  4   246,5   14,10673598 7,05336799
2   M3  4   266     17,64464036 8,822320179
2   M3  4   266,25  24,87803583 12,43901791
2   M3  4   266,75  16,17353806 8,086769029
2   M3  4   247,25  51,93184636 25,96592318
2   M3  4   258,25  37,93305507 18,96652753
2   M3  4   238,5   65,26612189 32,63306095
2   M3  4   260     19,8158186  9,907909298
2   M3  4   248,75  27,80137886 13,90068943
3   M3  4   108,75  26,65051594 13,32525797
3   M3  4   106,25  17,05627939 8,528139696
3   M3  4   109,25  17,93274472 8,966372362
3   M3  4   120,5   20,48576742 10,24288371
3   M3  4   107,25  2,5 1,25
3   M3  4   129     23,98610709 11,99305355
3   M3  4   131,5   15,75859554 7,879297769
3   M3  4   143,75  19,87251033 9,936255163
3   M3  4   117,75  80,267781   40,1338905
3   M3  4   139,5   36,24453982 18,12226991
3   M3  4   154,75  25,61737691 12,80868846

Here the example to be reproduced:

 alt2 <- structure(list(Treatment = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
 3, 3, 3, 3, 3, 3, 3), measurement = c("D", "D", "D", "D", "D", 
 "D", "D", "D", "D", "D", "F", "F", "F", "F", "F", "F", "F", "F", 
 "F", "F", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "F", 
 "F", "F", "F", "F", "F", "F", "F", "F", "F", "D", "D", "D", "D", 
 "D", "D", "D", "D", "D", "D", "F", "F", "F", "F", "F", "F", "F", 
 "F", "F", "F"), B1 = c(20.56, 19.7, 22.9, 21.1, 20.11, 22.98, 
 19.17, 21.67, 21.56, 20.56, 28.91, 28.01, 28.45, 29.23, 28.34, 
 28.1, 29.03, 28.22, 29.36, 29.87, 22.56, 21.48, 17.63, 20.78, 
 24.79, 25, 24.67, 23.51, 19.47, 22.85, 27.98, 28.1, 28.2, 28.22, 
 28.15, 28.97, 29.43, 29.05, 29.37, 29.39, 25.3, 24.56, 22.76, 
 23.47, 22.73, 24.98, 20.56, 27.1, 25.87, 23.46, 29.03, 29.67, 
 29.56, 28.69, 28.93, 29.01, 29.73, 29.77, 28.79, 28.83), B2 = c(19.78, 
 20.98, 22.27, 21.68, 21.56, 24.86, 23.45, 24.61, 23.56, 21.46, 
 28.56, 28.74, 28.37, 29.04, 29.85, 28.15, 27.99, 29.88, 28.74, 
 28.57, 21.47, 20.48, 25.12, 21.13, 22.76, 18.48, 22.76, 23.91, 
 17.27, 24.26, 28.64, 28.73, 28.47, 28.38, 28.26, 28.88, 29.06, 
 29.28, 29.59, 29.64, 21.45, 22.56, 27.45, 23.11, 20.03, 20.9, 
 21.1, 25.02, 24.16, 22.71, 28.54, 27.09, 29.03, 29.47, 29.58, 
 29.38, 28.05, 29.74, 28.5, 27.3), B3 = c(20.24, 16.42, 23.51, 
 22.41, 21.63, 24.61, 24.11, 23.57, 18.31, 19.61, 28.27, 29.07, 
 26.98, 29.33, 28.19, 28.54, 29.08, 29.7, 29.59, 29.58, 17.9, 
 21.45, 20.56, 22.74, 23.59, 20.01, 21.17, 22.11, 24.14, 23.35, 
 28.16, 28.38, 28.47, 28.94, 28.46, 27.47, 26.45, 28.49, 29.05, 
 29.79, 20.98, 26.93, 20.75, 19.63, 24.72, 24.07, 17.26, 25.66, 
 21.23, 21.78, 29.79, 29.64, 29.57, 29.32, 29.48, 29.77, 29.05, 
 29.11, 28.97, 29.59), B4 = c(25.61, 20.12, 19.42, 22.67, 24.31, 
 23.12, 18.24, 17.24, 21.58, 22.48, 29.01, 29.7, 28.77, 28.59, 
 28.74, 28.49, 28.08, 28.39, 28.4, 28.67, 19.02, 18.65, 20.72, 
 21.61, 20.41, 22.01, 23.71, 20.05, 22.13, 20.1, 28.46, 28.47, 
 28.38, 29.06, 28.48, 28.73, 27.9, 29.59, 29.4, 28.38, 24.31, 
 19.09, 24.89, 24.64, 21.47, 25.04, 22.51, 21.1, 20.27, 23.64, 
 28.57, 28.08, 29.19, 29.61, 29.84, 28.07, 29.18, 29.59, 29.58, 
 28.22), N = c(4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
 4, 4)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, 
 -60L))

the code used is this:

library(ggplot2)

ggplot(alt2, aes(x = Treatment)) +
geom_bar(aes(y=len, fill=TIME),
stat = "identity", alpha = 0.5, position =
   position_dodge()
) +
scale_fill_manual(values = c("grey", "black", "blue")) +
geom_errorbar(aes(ymin = len-se, ymax = len+se, group = TIME),
            width = 0.2, colour = "black",
            position = position_dodge(0.9)
) +
theme_light() +
xlab("doses") +
ylab("len")

I dont understand why i got that figure.

I am working with 3 doses(1,2,3) and in different times (M1,M2,M3). But I am getting this figure with multiple error lines. How can I solve this ?.

enter image description here

  • 2
    Please share your data to make your question reproducible. If your data is only 9 rows, `dput(alt2)` will be great. If your data is more than 9 rows, that's part of the problem, but please choose a illustrative subset to share, e.g. `dput(alt2[1:18, ])` for the first 18 rows. – Gregor Thomas Jan 24 '22 at 15:14
  • I think my error is related to the repetitions. I think I need to get the mean by group... – Carla Flores Jan 24 '22 at 17:22
  • 2
    Yes, calculate the mean and se by group. [Here's the FAQ on how to do that](https://stackoverflow.com/q/11562656/903061). If you need more help, please reshare the data using `dput()` so it is copy/pasteable into R. – Gregor Thomas Jan 24 '22 at 17:33

0 Answers0