# [R] ranking the results of a questionnaire

Wolfgang Lindner LindnerW at t-online.de
Fri Nov 28 20:16:48 CET 2008

```dear experts,

I reproduced an experiment (questionnaire) some times.
The result of the experiment is a vector of 5 factors, say (A,B,C,D,E).
In the original article the result is given in 5 pairs of mean and stDev for
A .. E, e.g. mean_A=37.4 and sd_A=8.1.
The interval for A,B,C,D,E values is 0..50. The original data frame is not
available.

For a comparison of my results L=(A',B',C',D',E')  with the original
G=(A,B,C,D,E)  we can interpret that smaller sd-values are 'better'.
But for the means the interpretation is a little bit complicated:
a smaller mean value of A or B or E is 'better', but a bigger mean value for
C or D is 'better'.

To construct a quantified value of being 'better' and to rank my data L vs.
the data G, I wrote a kind of an signed distance-function.
Here is my simple code and an small example run:

R version 2.7.1 (2008-06-23)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

> L<-c(32.8,5.3,  26.3,9.0,  35.1,6.2,  33.4,6.3,  22.9,12.9)
> G<-c(37.4,8.1,  30.6,9.7,  32.0,7.9,  29.7, 9.0,  17.1,10.8)

> sigdist<- function (L,G)
sqrt(
sign( G-L )*(G-L)^2
+   sign( G-L )*(G-L)^2
+ sign( G-L )*(G-L)^2
+   sign( G-L )*(G-L)^2
- sign( G-L )*(G-L)^2
+   sign( G-L)*(G-L)^2
- sign( G-L )*(G-L)^2
+   sign( G-L )*(G-L)^2
+ sign( G-L )*(G-L)^2
+   sign( G-L )*(G-L)^2
)

> sigdist(L,G)
 6.588627

I like to interpret the positive value 6.588 that  'the L vector is better
then G vector w.r.t. sigdist'.

My questions are:

1. are there build-in functions in R calculating some (distance?)value with
the possibility of a similar interpretation?
2. are there other ideas for a ranking of the experimental results L and G?

Any comments, critique or hints are very welcome.

Sincerely

Wolfgang

```