Hi everyone,

I've been bashing my head against this for days now, and can't figure out
what to do.

I have the following dataframe
header    appetitive stimulus    aversive stimulus    chaining
contingency    discriminative stimulus    extinction    intermittent
reinforcement    negative reinforcer    operant response    place
learning    positive reinforcer    punishment    reinforcement schedules
response rate    secondary reinforcement    spontaneous recovery    variance
spontaneous recovery    -3    -2    0    -3    -3    -16    -5    1    16
-1    7    1    -1    11    -2    0    49.73
negative reinforcer    -1    -15    4    -1    8    2    -1    0    -5
2    -6    14    -1    -2    2    0    38.80
appetitive stimulus    0    2    -1    2    1    1    0    -2    -6    4
-14    0    4    9    -1    1    24.13
aversive stimulus    -4    0    0    2    9    1    1    -12    0    3
2    -7    0    2    2    1    21.20
discriminative stimulus    -3    5    0    1    0    1    -1    7    -8
-3    -2    10    2    -3    -6    0    20.80
intermittent reinforcement    3    2    -3    0    0    -3    0    0
-7    -2    7    1    -4    -7    9    4    19.73
place learning    3    3    -2    -4    -2    -2    2    -2    -4    0
7    -3    11    -6    -1    0    19.07
extinction    4    5    5    0    2    0    -3    0    -1    3    0    3
-4    -2    -1    -11    16.00
chaining    -1    -4    0    -3    0    0    3    7    -1    -6    -1
9    -5    0    1    1    15.33
positive reinforcer    -11    -4    1    0    -1    -1    1    -2    -1
5    0    1    3    4    0    5    14.80
response rate    4    6    0    -2    -1    -2    -4    -1    2    1    0
-2    -7    0    -2    8    13.60
punishment    0    -7    6    0    -3    -1    3    7    0    2    -2
0    -3    -3    1    0    12.00
operant response    -1    0    0    -1    0    2    -4    -6    0    3
-5    1    -2    5    2    6    10.80
secondary reinforcement    -2    -1    1    3    -5    -1    8    -1
-6    0    2    1    1    0    0    0    9.87
contingency    1    1    -6    0    -1    1    3    0    -3    5    3
-1    -4    -2    -1    4    8.67
reinforcement schedules    1    2    0    2    0    -3    -4    4    0
3    2    0    0    -5    -2    0    6.13

which is ordered according to the variance column (I manually ordered this
in excel and wrote the data to file as a csv).  I need to enforce this order
on the levels of $header and I don't know how to do that.
levels(related.differences$header)
 [1] "appetitive stimulus"        "aversive stimulus"
"chaining"                   "contingency"                "discriminative
stimulus"
 [6] "extinction"                 "intermittent reinforcement" "negative
reinforcer"        "operant response"           "place learning"
[11] "positive reinforcer"        "punishment"
"reinforcement schedules"    "response rate"              "secondary
reinforcement"
[16] "spontaneous recovery"

I've tried
levels(related.differences$header) <- as.vector(related.differences$header)
levels(related.differences$header)
[1] "spontaneous recovery"       "negative reinforcer"        "appetitive
stimulus"        "aversive stimulus"          "discriminative stimulus"
 [6] "intermittent reinforcement" "place learning"
"extinction"                 "chaining"                   "positive
reinforcer"
[11] "response rate"              "punishment"                 "operant
response"           "secondary reinforcement"    "contingency"

[16] "reinforcement schedules"

which looks right, but when I print the dataframe to screen, the order of
$header is pooched, while the data is still in the correct order or if I
submit the dataframe to ggplot2 via qplot(), the headers are in the correct
order, but the data is in order as though the levels were alphabetical. :(

qplot(appetitive.stimulus, header, data=related.differences, size=variance,
colour="Appetitive Stimulus", xlim=c(-20,20), main="title",
xlab="Differences", ylab="Header Concepts")

At the end of the day, all I want to do is order the dataframe and headers
and levels according to the variance, so that when I graph all the
variables, the size of the dots either gets bigger or smaller depending on
the variance as opposed to the alphabetical order which makes it appear
random.

If you can tell me what i'm doing wrong please let me know.
many thanks,
emilio

	[[alternative HTML version deleted]]

