[R] problem with factor in list (same name for diffrent category)

Thomas Kuster r at fam-kuster.ch
Thu Aug 3 14:34:17 CEST 2006


Hello

I try to ignore the problems with the umlaut.
I read the file in with:

> library("foreign")
> daten <- read.spss(filename)

Then I want select a "Vorlage" (vote), but if I want select for example [6] 
and not 6 and 7 how can I select it? The real name is a other problem, but I 
can solve this via date.

> levels(daten$PROJETX)
  [1] "Bg Stammzellenforschung"
  [2] "Bb  "
  [3] "Bb Neugestaltung des Finanzausgleichs"
  [4] ""
  [5] "EV Postdienste f"
  [6] "Bb "
  [7] "Bb "
  [8] "Bg Steuerpaket"
  [9] "Bb Anhebung der Mehrwertsteuer s"
 [10] "11. AHV-Revision"
 [11] "Volkinitiative Lebenslange Verwahrung"
 [12] ""
   .
   .
   .

Select with:
> pos <- daten$PROJETX=="11. AHV-Revision"
> summary(pos)
   Mode   FALSE    TRUE
logical  200373    1002

This is okay.

> pos <- daten$PROJETX==(levels(daten$PROJETX)[6])
> summary(pos)
   Mode   FALSE    TRUE
logical  194904    6471

Too many TRUE's.

Thomas



More information about the R-help mailing list