side by side boxplot in R

Kyle Sliker

I am trying to make a side-by-side box and whisker plot of durasec broken out by placement and media

df <- read.csv("http://citadel.sjfc.edu/faculty/ageraci/data/dataset-nci-2012-subset1.csv")
str(df)
'data.frame':   11475 obs. of  7 variables:
 $ time     : int  1 1 1 1 1 1 1 1 1 1 ...
 $ durasec  : int  168 149 179 155 90 133 17 14 14 18 ...
 $ placement: int  401 402 403 403 403 403 403 403 403 403 ...
 $ format   : int  8 9 8 8 9 8 12 12 12 12 ...
 $ focus    : int  1 1 1 1 1 1 3 3 1 1 ...
 $ topic    : int  5 5 5 2 2 2 26 26 11 24 ...
 $ media    : int  4 4 4 4 4 4 4 4 4 4 ...
favstats(~durasec | placement + media, data =df)
401.4   14  120.25  164.5   197.00  754 171.39686   90.85643    446 0
402.4   9   92.00   143.0   182.00  619 157.20935   107.92586   449 0
403.4   3   23.00   54.0    141.00  807 90.18696    90.50816    4172    0
401.5   12  94.25   165.5   254.75  1136    215.05121   180.52376   742 0
402.5   7   98.50   181.0   306.00  716 211.23293   145.88735   747 0
403.5   3   34.00   96.0    173.50  1098    124.85180   112.56758   4919    0
6 rows
bwplot(placement + media ~ durasec, data = df)

When I run this last piece of code it gives me a box and whisker plot but on the Y axis instead of the combinations of 401.4 through 403.5 like in the favstats, it just gives me 1 through 5 and the data doesn't appear to exactly match the favstats.

How can I get it to display the six combinations and their data like in the favstats?

Bappa Das

You can try the following code

library(lattice)
bwplot(durasec ~ as.factor(df$placement) | as.factor(df$media), data = df)

enter image description here

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados