Hi,

I'm having a problem with spss.read reversing my factor input.

Here is the input copied from the spss data editor:

color cost
1 2.30
2 2.40
3 3.00
1 2.10
1 1.00
1 2.00
2 4.00
2 3.20
2 2.33
3 2.44
3 2.55

For color, red=1, blue=2, and green = 3. It's type is 'String' and

>out=read.spss(file)
>out

$COLOR
[1] green blue red green green green blue blue blue red red 
Levels: red blue green

$COST
[1] 2.30 2.40 3.00 2.10 1.00 2.00 4.00 3.20 2.33 2.44 2.55

attr(,"label.table")
attr(,"label.table")$COLOR
green blue red 
3 2 1 

attr(,"label.table")$COST
NULL

attr(,"variable.labels")
COLOR COST 
"color" "cost" 

=====EOF===================

Notice that the $COLOR factor data are inverted, looking at the integer 
output
we see:

> as.integer(out$COLOR)
[1] 3 2 1 3 3 3 2 2 2 1 1

The spss original data looks like this:
1 2 3 1 1 1 2 2 2 3 3

I can easily invert the output mathematically with:
q = sapply(m,function(x){ x + 2*(median(unique(m))-x)})

(m is composed of sequential integers starting at one)

,but it seems as though something wrong is happening with read.spss.

Any ideas?

Joel Bremson
Graduate Student
UC Davis

	[[alternative HTML version deleted]]


