[R] boxplot including null info from dataframe, not with SQLite dataframe
Ben Bolker
bolker at ufl.edu
Fri Sep 5 21:20:27 CEST 2008
Coey Minear <cminear <at> securecomputing.com> writes:
>
> I have been trying to use R to gather some information from parsed log
> files (as part of examining some performance issues). I parsed the
> log files and put the data into an SQLite database, and then used
> RSQLite to load the data into R. The fields of interest are
> controller, action and total_time: controller and action have string
> values; total_time has a decimal value.
>
> I first did the following box plot to find the problem controllers.
> boxplot(total_time ~ controller, all_data)
>
> Having identified one controller of interest (let's say
> "BadController"), I then wanted to then focus on the actions
> associated with that controller. So I did this:
> boxplot(total_time ~ action, subset(all_data, controller == "BadController"))
>
> This gave me a plot I was expecting: just the actions which are
> associated with "BadController". However, I'd done this work on a
> FreeBSD system, and then I wanted to print it, and the easiest means
> seemed to re-plot using R on Windows. So I wrote the data to a file,
> moved it to Windows and loaded it up there.
>
> On FreeBSD:
> write.table(all_data, "datafile.R")
>
> On Windows:
> all_data <- read.table("datafile.R")
>
I'm guessing that you want
bad <- subset(all_data,controller=="BadController")
bad$action <- factor(bad$action)
boxplot(total_time ~ action)
Subsetting doesn't drop factor levels that don't
occur, which is an unfortunate design decision ...
Ben Bolker
More information about the R-help
mailing list