[R] boxplot order of the levels

2006-08-22 Thread Thomas Kuster
hello

i drew a boxplot with:
 boxplot(voxit$AGE ~ voxit$A02X)
and the boxes are from left to right:
Ja Leer Nein wn k.A.

 levels(voxit$A02X)
[1] Ja   Leer Nein wn   k.A. 98
there are no entries with 98

but i want:
Ja Nein Leer wn k.A.

how can i change the order of the boxes

bye
thomas

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read.spss and umlaut

2006-08-04 Thread Thomas Kuster
Hello

Am Donnerstag, 3. August 2006 15.34 schrieb Thomas Lumley:
 On Thu, 3 Aug 2006, Thomas Kuster wrote:
  Hello
 
  Am Mittwoch, 2. August 2006 17.11 schrieb Thomas Lumley:
...
 You haven't shown anything that indicates that the C code stopped reading.
 More likely R just stops displaying when it gets to an illegal byte
 sequence.  You could use nchar() to count the bytes in the string to find
 out.

If I change the translatable characters (overwrite the 0 between :#@'= and 
~000 with ÄÖÜäöü). I can read in the file an every ÄÖÜäöü ist a withspace:
 daten - read.spss(projets_umlaut.por)
 levels(daten$PROJETX)
  [1] Bg Stammzellenforschung
  [2] Bb   ber eine neue Finanzordnung
  [3] Bb Neugestaltung des Finanzausgleichs
  [4]  nderrung Bg  EOG Mutterschafturlaub
  [5] EV Postdienste f r alle
  [6] Bb  ber B rgerrechtserwerb 3. Generation
  [7] Bb  ber erleichterte Einb rung 2. Generation
  [8] Bg Steuerpaket
   .
   .
   .
 levels(daten$PROJETX)[208]
[1] EV Gleiche Rechte f r Mann und Frau Gegenvorschlag
 charToRaw(levels(daten$PROJETX)[208])
 [1] 45 56 20 47 6c 65 69 63 68 65 20 52 65 63 68 74 65 20 66 20 72 20 4d 61 
6e
[26] 6e 20 75 6e 64 20 46 72 61 75 20 47 65 67 65 6e 76 6f 72 73 63 68 6c 61 
67

without change the table I get:
 daten - read.spss(projets.por)
 charToRaw(levels(daten$PROJETX)[208])
 [1] 45 56 20 47 6c 65 69 63 68 65 20 52 65 63 68 74 65 20 66

The SPSS file is from:
http://voxit.sidos.ch/update.asp?lang=d
- Download der kumulierten Dateien Version 2.0

You must accept this:
The Standardized Post-Vote Surveys:
http://voxit.sidos.ch/agreement.asp?lang=emenu=0

Thomas

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read.spss and umlaut

2006-08-03 Thread Thomas Kuster
Hello

Am Mittwoch, 2. August 2006 17.11 schrieb Thomas Lumley:
 This sounds like a conflict between encodings -- eg if R is assuming UTF-8
 and the file is encoding in Latin-1 then the sequence
 U+00FC : LATIN SMALL LETTER U WITH DIAERESIS
 U+0072 : LATIN SMALL LETTER R
 is coded as FC72 in the file, which is an illegal byte sequence in UTF-8.

Hex:  74 65 20 66 fc 72 20 61 6c 6c 65 53 45 2f 31 36
Text:  t  e f  ü  r a  l  l  e  S  E  /  1  6

 The underlying C code (being written in the US quite a long time ago)
 doesn't know about encodings, and I don't know what the rules are in SPSS
 for valid characters (I suspect that in these old portable file formats it
 probably just reads and writes bytes, leaving it up to the OS to interpret
 them.

But why stopp the C code reading? Is / not the endmark of the string? What 
is the problem, if I chance that in the source?

 You could try running R in a non-UTF-8 locale to see if it helps.

I think my local is non-UTF-8 (de_CH, isolatin). How can I check that, and set 
an other temporary?

A dirty hack like this:
sed s/ä/ae/g | sed s/ö/oe/g | sed s/ü/ue/g | sed s/Ä/Ae/g | sed s/Ö/Oe/g | sed 
s/Ü/Ue/g
didn't work (file 'projets_non_umlaut.por' is not in any supported SPSS 
format).

Thomas

 If anyone has definitive information about how SPSS represents strings and
 decides on valid characters that might be useful too.

   -thomas

  library(foreign)
  spssdaten - read.spss(projets.por)
  attr(spssdaten$PROJETX, value.labels)[1:20]
 
   Bg Stammzellenforschung  Bb
   863  
  862 Bb Neugestaltung des Finanzausgleichs
   861  
  854 EV Postdienste f   Bb 853
852 Bb Bg Steuerpaket 851  
  843 Bb Anhebung der Mehrwertsteuer s 
  11. AHV-Revision 842  
  841 Volkinitiative Lebenslange Verwahrung
   833  
  832 Gegenentwurf zur Avanti EV Lehrstellen-Initiative 831
824 EV Moratorium Plus   
  EV Strom ohne Atom 823   822 EV Ja zu
  fairen Mieten   EV Gleiche Rechte f 821  
  815 EV GesundheitsinitiativeEV
  Sonntags-Initiative 814   813
 
  The SPSS-File is okay:
  system(cat projets.por |grep Postdienste)
 
  echtserwerb 3. GenerationSD/N/EV Postdienste für alleSE/16/Änderrung Bg 
  EOG Mut
 
  How can I read the SPSS-File with the Umlaut?
 
  Bye
  Thomas Kuster
 
  R: 2.1.0 (2005-04-18)
  OS: Debian Linux, 2.6.10-isgee-neptun-1
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html and provide commented,
  minimal, self-contained, reproducible code.

 Thomas Lumley Assoc. Professor, Biostatistics
 [EMAIL PROTECTED] University of Washington, Seattle

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] run self written functions

2006-08-03 Thread Thomas Kuster
Hello

Am Donnerstag, 3. August 2006 09.36 schrieb Antje:
 Hello,

 I'm not sure if I'm in the right place with my question...
 I'm running R on Windows and wrote a function and saved it as .R file.
 It looks like this:

 bmi - function(weight, height) {
 bmi - weight / height^2
 bmi
 }

 If I want to use this function, I have to mark everything and then press
 Ctrl-R. But then everything single line is executed on the command line,
 which means that I will loose my history when the code becomes longer.
 Further, I wonder if there is any way to do some output for control
 within the function (or any other possibilities to debug in a way).

source(your-r-file.R)
mybmi - bmi(180, 70)

 Maybe, I have chosen a completely wrong way? I only want to make it easy
 to create some graphical visualizations of data which will be read in by
 csv. files, has to be converted and then displayed depending on some
 displaying parameters.

look here (directory R):
http://tomix.homelinux.org/~thomas/eth/5_semester/semesterarbeit_WS_2005_2006/
auswertung.R is the main file.


 Ciao,
 Antje

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented, minimal,
 self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2006-08-03 Thread Thomas Kuster
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   FALSETRUE
logical  2003731002

This is okay.

 pos - daten$PROJETX==(levels(daten$PROJETX)[6])
 summary(pos)
   Mode   FALSETRUE
logical  1949046471

Too many TRUE's.

Thomas

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] read.spss and umlaut

2006-08-02 Thread Thomas Kuster
Hello

When I read a SPSS *.por file with read.spss everything after a umlaut is 
missing:

 library(foreign)
 spssdaten - read.spss(projets.por)
 attr(spssdaten$PROJETX, value.labels)[1:20]
  Bg Stammzellenforschung  Bb
  863   862
Bb Neugestaltung des Finanzausgleichs
  861   854
 EV Postdienste f   Bb
  853   852
  Bb Bg Steuerpaket
  851   843
 Bb Anhebung der Mehrwertsteuer s  11. AHV-Revision
  842   841
Volkinitiative Lebenslange Verwahrung
  833   832
  Gegenentwurf zur Avanti EV Lehrstellen-Initiative
  831   824
   EV Moratorium PlusEV Strom ohne Atom
  823   822
   EV Ja zu fairen Mieten   EV Gleiche Rechte f
  821   815
 EV GesundheitsinitiativeEV Sonntags-Initiative
  814   813

The SPSS-File is okay:
 system(cat projets.por |grep Postdienste)
echtserwerb 3. GenerationSD/N/EV Postdienste für alleSE/16/Änderrung Bg  EOG 
Mut

How can I read the SPSS-File with the Umlaut?

Bye
Thomas Kuster

R: 2.1.0 (2005-04-18)
OS: Debian Sarge (Version 2.6.10-isgee-neptun-1)

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] read.spss and umlaut

2006-08-02 Thread Thomas Kuster
Hello

When I read a SPSS *.por file with read.spss everything after a umlaut is 
missing:

 library(foreign)
 spssdaten - read.spss(projets.por)
 attr(spssdaten$PROJETX, value.labels)[1:20]
  Bg Stammzellenforschung  Bb
  863   862
Bb Neugestaltung des Finanzausgleichs
  861   854
 EV Postdienste f   Bb
  853   852
  Bb Bg Steuerpaket
  851   843
 Bb Anhebung der Mehrwertsteuer s  11. AHV-Revision
  842   841
Volkinitiative Lebenslange Verwahrung
  833   832
  Gegenentwurf zur Avanti EV Lehrstellen-Initiative
  831   824
   EV Moratorium PlusEV Strom ohne Atom
  823   822
   EV Ja zu fairen Mieten   EV Gleiche Rechte f
  821   815
 EV GesundheitsinitiativeEV Sonntags-Initiative
  814   813

The SPSS-File is okay:
 system(cat projets.por |grep Postdienste)
echtserwerb 3. GenerationSD/N/EV Postdienste für alleSE/16/Änderrung Bg  EOG 
Mut

How can I read the SPSS-File with the Umlaut?

Bye
Thomas Kuster

R: 2.1.0 (2005-04-18)
OS: Debian Linux, 2.6.10-isgee-neptun-1

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.