boxplot is not ok

Hi, can anybody help me with my boxplot. Why the SPI 9 is divided it should be only SPI3 SPI6 SPI 9 and SPI12, not SPI 9 SPI 9


I suspect you have leading and/or trailing spaces in some instances of SPI 9. You can use the unique() function to list the different values in a column.

1 Like

Would you ming posting you R code?
That would simplify investigation.

Hi, the problem is solved but can you help me, how can i rearrange the position of plot, i mean it should be SPI3, SPI6, SPI9 and SPI12 but the SPI12 comes out first.


df.m <- melt(testtukui, id.var = "MONTH")
ggplot(data = df.m, aes(x=variable, y=value)) + geom_boxplot(aes(fill=MONTH)) + ylab("SPI") + xlab(NULL)

this is my script.

and my data is like:


You can force the order of the x axis categories by using the factor() function.

df.m$MONTH <- factor(df.m$MONTH, levels = c("SPI3", "SPI6", "SPI9", "SPI12"))

Another alternative to @FJCC's suggestion may be to use "%>% select()" before "melt".
testtukui <- testtukui %>% select(MONTH, SPI3, SPI6, SPI9, SPI12)

Hi. I need help. Why I get

Error in $<*tmp*, MONTH, value = integer(0)) :
replacement has 0 rows, data has 6027

hi. it says

could not find function "%>%"

why is that? :frowning:

The pipe %>% is part of the magrittr package. You have to load either that package or the dplyr package that will import magrittr. Use


For your other error, please show your code or, better, a reproducible example.


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.