Pergunta

I have a boxplot looking like this :

Boxplot( ~ km_piste, data=slide, id.method="y", col="orange")

enter image description here

The outliers name are shown because I set up the first column as:

row.names(slide) <- as.character(slide$data_name)

Now I would like to know how to make a new multiple boxplot. I would like to have 2 boxplot on the same image. The datas are still in the slide database. The name of the 2 columns are :

  1. ski_parc (slide$ski_parc)
  2. snow_parc (slide$snow_parc)

I can't figure out how to put the 2 boxplot on the same image with showing :

  • name of the outliers like on the print screen for each of the 2 boxplot
  • name of the boxplot under each boxplot in order to recognize them

Edit: here is a link of a my database slide

Foi útil?

Solução

The second argument to car::Boxplot is 'g' for use as a grouping variable. At the moment we cannot tell what your dataframe looks like and it sounds as though it might not be in the long format which Boxplot expects. If there were a single column say "area_type" that had values of "ski_parc" and "snow_parc" you could use this format:

Boxplot( ~ km_piste, g= area_type, data=slide, id.method="y", col=c("orange", "red") )

The use of na.omit had nothing to do with the labeling of the points. It was the choice to use id.method="y". When there are multiple groups the x-axis gets labeled with their levels.

Try this:

snow_parc <- data.frame(parc =c(slides$snow_parc, slides$ski_parc), 
              type=rep(c("snow_parc", "ski_parc"), each=40))
Boxplot(parc~type, data=snow_parc, id.method = "y")

(There were no outliers.)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top