[R] Plots from categorial data

hadley wickham h.wickham at gmail.com
Sun Jul 1 12:20:39 CEST 2007


Perhaps this will do what you want:

library(ggplot2)
qplot(filter_setting, avg.hit, data=data, colour=ocrtool, geom="line")

find out more about ggplot2 at http://had.co.nz/ggplot2

Hadley

On 7/1/07, Christoph Krammer <ck at altaica.de> wrote:
> Hello everybody,
>
> Since my first message was caught by the spam filter, I just try to do it
> again:
>
> I want to use R to generate plots from categorial data. The data contains
> results from OCR scans over images with are preprocessed by different image
> filtering techniques. A small sample data set looks as following:
>
> > data <- read.csv("d:/tmp_da/sql_data/filter_d_tool.csv", header=T)
> > data
>       ocrtool filter_setting avg.hit.
> 1  FineReader            2x1    0.383
> 2  FineReader            2x2    0.488
> 3  FineReader            3x2    0.268
> 4  FineReader            3x3    0.198
> 5  FineReader            4x3    0.081
> 6  FineReader            4x4    0.056
> 7        gocr            2x1    0.153
> 8        gocr            2x2    0.102
> 9        gocr            3x2    0.047
> 10       gocr            3x3    0.052
> 11       gocr            4x3    0.014
> 12       gocr            4x4    0.002
> 13      ocrad            2x1    0.085
> 14      ocrad            2x2    0.094
> 15      ocrad            3x2    0.045
> 16      ocrad            3x3    0.050
> 17      ocrad            4x3    0.025
> 18      ocrad            4x4    0.009
>
>
> I now want to draw a plot with the categories (filter_setting) as X axis,
> and the avg_hit as Y axis. There should be lines for each ocrtool.
>
> But when I draw a plot, the resulting plot always contains bars, even if I
> specify type="n".
> > plot(data$filter_setting, data$avg.hit., type="n")
>
> When I only plot the categories, without data, there appear strange grey
> (but empty) boxes.
> > plot(data$filter_setting, type="n")
>
> Who do I get a clean white box to draw the different lines in?
>
> Thanks and regards,
>  Christoph
>
> ---
> Christoph Krammer
> Student
>
> University of Mannheim
> Laboratory for Dependable Distributed Systems A5, 6
> 68131 Mannheim
> Germany
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list