[R] Data frame manipulation - newbie question

From: José Augusto M. de Andrade Junior <jamaj69_at_gmail.com>
Date: Thu, 3 Jan 2008 08:53:38 -0200


Hi all,

Could someone please explain how can i efficientily query a data frame with several factors, as shown below:



Data frame: pt.knn

row | k.idx | step.forwd | pt.num | model | prev | value | abs.error
1      200        0                  1             lm          09
10.5       1.5
2      200        0                  2             lm          11
10.5       1.5
3      201        1                  1             lm          10
12          2.0
4      201        1                  2             lm          12
12          2.0
5      202        2                  1             lm          12
12.1       0.1
6      202        2                  2             lm          12
12.1       0.1
7      200        0                  1             rlm         10.1
10.5       0.4
8      200        0                  2             rlm         10.3
10.5       0.2
9      201        1                  1             rlm         11.6
12          0.4
10    201        1                  2             rlm         11.4
12          0.6
11    202        2                  1             rlm         11.8
12.1       0.1
12    202        2                  2             rlm         11.9
12.1       0.2

----------------------------------------------------------------------------------------------------------

k.idx, step.forwd, pt.num and model columns are FACTORS. prev, value, abs.error are numeric

I need to take the mean value of the numeric columns (prev, value and abs.error) for each k.idx and step.forwd and model. So: rows 1 and 2, 3 and 4, 5 and 6,7 and 8, 9 and 10, 11 and 12 must be grouped together.

Next, i need to plot a boxplot of the mean(abs.error) of each model for each k.idx.
I need to compare the abs.error of the two models for each step and the mean overall abs.error of each model. And so on.

I read the manuals, but the examples there are too simple. I know how to do this manipulation in a "brute force" manner, but i wish to learn how to work the right way with R.

Could someone help me?
Thanks in advance.

José Augusto
Undergraduate student
University of São Paulo
Business Administration Faculty



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. Received on Thu 03 Jan 2008 - 10:59:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 06 Jan 2008 - 17:30:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive