[R] Plot only a subset of all factors in dataframe

Henrique Dallazuanna wwwhsd at gmail.com
Fri Jan 4 18:31:53 CET 2008


Try this:

plot(subset(df[,c(3,5)], type %in% c("exact", "broader1", "narrower4")))


On 04/01/2008, Laura Hollink <laurah at cs.vu.nl> wrote:
> Hi all,
> I have a dataframe called 'table' in which both factors and numerical
> values are stored.
>
>  > dim(table)
> [1] 990   6
>
> The fist 10 lines of table, to get an idea:
>
>  > table[1:10,]
>    QueryNo    Query  type Ret Prec  Rec
> 1        1   Sports exact   1    1 0.01
> 2        5   Office exact   0  NaN 0.00
> 3        6  Meeting exact   0  NaN 0.00
> 4        7   Studio exact   0  NaN 0.00
> 5        9 Building exact   0  NaN 0.00
> 6       10   Desert exact   1    1 0.01
> 7       12 Mountain exact   0  NaN 0.00
> 8       13     Road exact   0  NaN 0.00
> 9       14      Sky exact   0  NaN 0.00
> 10      15     Snow exact   0  NaN 0.00
>
> I want to plot column 5 (numerical values) against column 3 (factors).
>
> plot(table[,c(3,5)]) works fine.
>
> However, I don't want to include all 30 levels of the factor in the
> plot. I would like a plot of just 5 factors: "exact", "broader1",
> "narrower4", etc.
>
> Could anyone tell me how to do this, or where to find information about
> this?
>
> Thanks!
> Laura
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list