Removed 1 rows containing missing values

I am trying to use a split violin plot with aesthetics but it throws an error
|Warning: e[38;5;232mRemoved 1 rows containing missing values (geom_segment()).e[39m|
|Warning: e[38;5;232mRemoved 1 rows containing missing values (geom_segment()).e[39m|
|Warning: e[38;5;232mRemoved 1 rows containing missing values (geom_segment()).e[39m|
|Warning: e[38;5;232mRemoved 1 rows containing missing values (geom_segment()).e[39m|
|Warning: e[38;5;232mRemoved 1 rows containing missing values (geom_segment()).e[39m|
|Warning: e[38;5;232mRemoved 1 rows containing missing values (geom_segment()).e[39m|

resultspe <- data.frame(
  subject = output1[1], 
  Group = output1[2],
  Lexical.precision = output1[3],
  Stroop.interference = priming.effect)

ggplot(resultspe, aes(group, Stroop.interference, fill = Lexical_precisionHighLow_group)) + 
  theme_classic() +
  theme(legend.position = "none") +
  geom_half_violin(side = "r") +
  ylab ("Stroop interference (ms)") +
 geom_boxplot(width = .2, alpha = 0.6, fatten = NULL, show.legend = FALSE) +
stat_summary(fun.data = "mean_se", geom = "pointrange", show.legend = F, position = position_dodge(.175)) +
scale_x_discrete(name = "group",
labels = c("NT", "PWD", "PWS")) +
scale_y_continuous(name = "Stroop interference(ms)") +
scale_fill_brewer(palette = "Dark2",
name = "Lexical Precision") +
theme_minimal()

Any advice how to solve it? Looked at the data, no missing values, manipulated y axis to be 1000 and 1000-there is no issue.

Hi Gerald,

It's generally difficult to know what triggered the warning without looking at your data, but it is a warning, not an error, so there may be nothing that's needs solving — a warning is simply a way a alerting you to the fact that something may be happening that you didn't intend to happen, whereas an error message is a sign that the code failed.

If you'd like to be certain that your code is behaving as you intended, then the next step would be to share your data. Otherwise, my guess is that your data contains an x-value (a value of the group variable) for which there is only one y-value (a value of the Stroop.interference variable). This means that when the function mean_se() (that you invoked in the stat_summary() layer) is applied at that x-value, the output contains NAs, which prevents the geom_segment()function from producing an error bar for that x-value:

library(ggplot2)
y_values <- 1:2
y_values |>  mean_se()
#>     y ymin ymax
#> 1 1.5    1    2

y_values <- 3
y_values |>  mean_se()
#>   y ymin ymax
#> 1 3   NA   NA

Created on 2024-05-22 with reprex v2.0.2

1 Like

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here between
```

```