[R] Ignorant lack of bliss : summarise table by column attribute
Rory Campbell-Lange
rory at campbell-lange.net
Tue Apr 6 16:07:29 CEST 2004
Having read the list posting guidelines I fear my first post is about to
break the rules. Apologies in advance.
We have been asked to produce some graphs of relative performance of 3
groups of people in relation to the trend of their previous performance.
I am neither a mathematician or a statistician, but wondered if R (which
I have been using as a desktop calculator!) and some knowledge from this
list may be able to help.
We have a dataset something like this:
group | previousavg | lastreading | finalreading
------------------------------------------------
1 | 9.5 | 10 | 12
1 | 7 | 9 | 11
1 | 12 | 11 | 12
2 | 13 | 14 | 16
2 | 11 | 10 | 9
3 | 10 | 10 | 10.5
3 | 8.5 | 10 | 12
I need to produce some graphs typifying the change for each group
between a _projected_ final reading and the final reading given. The
time difference between previousavg and lastreading is 1/2 that between
lastreading and finalreading.
Where I have got to so far:
I have read the result set (less than 200 rows) into a table 'results',
attached it and then rather crudely constructed projected figures :
results$projected =
((lastreading - previousavg) * 2) + lastreading
then I can see the differentials between projected and finalreading:
> result$projected - results$finalreading
[1] -1.4 6.9 1.1 3.4 0.0 3.6 -3.8 0.1 -0.1 0.9 1.2 -3.4 -1.5 0.1 5.6
[16] -3.3 -1.9 0.9 -3.1 1.5 0.7 -1.6 -0.3 1.1 -0.1 -0.6 1.5 0.2 0.8 -1.0
[31] 0.8 -0.5 1.9 -4.0 -3.3 3.1 2.8 -0.6 1.2 2.0 -1.9 -1.6 -1.1 -3.9 NA
...
Aims:
- Summarise these by groups (I can't work out how to use tapply...)
- Produce a sensible 'typification' of each group's change in
relation to the projected figure. I assume this would use a
statistical algorithm to exclude exceptions.
- Plot the 3 'typifications' in sensible relation to each other,
possibly with data points showing the source of these lines.
My sincere apologies if this is completely off-topic for this list. I'm
hoping to learn a little by understanding how certain functions are used
(approaching this like a programmer rather than a statistician.)
If I needed to learn more is the book "Introductory Statistics with R" a
good place to start?
Thanks
Rory
--
Rory Campbell-Lange
<rory at campbell-lange.net>
<www.campbell-lange.net>
More information about the R-help
mailing list