[R-lang] vowel space ellipses (and IPA fonts)

Stefan Evert stefan.evert at uos.de
Wed Jun 6 00:24:43 PDT 2007


> Below I give some code I wrote for a student to plot vowel space
> ellipses. Five questions and one comment:
>
> (1) Did I just reinvent the wheel? Does anybody already have better R
> code to do this?

Hi James, I don't have better R code, but I've got some comments on  
your other questions (and a question on your comment :o).

> (2) How do I get the axes to appear on the right and top, instead of
> left and bottom? I couldn't find parameters for doing this without
> drawing the whole thing piece by piece.

As far as I know, if you want the axes in nonstandard places, you  
have to draw them yourself piece by piece (which, of course, gives  
you a lot of flexibility).  If you need that often, I suggest that  
you set up a utility function to cover the most common cases.

> (3) When the user chooses to plot only the ellipses, the only way I
> could figure out how to get started was to plot the first vowel  
> dots in
> white so they'd be invisible. Surely there's a better way to do this.

If I understand you correctly, you probably want something like this:

if (!dots) {
   plot(0, 0, type="n", # "n" stands for "no plot"
    ylim=c(max(F1),min(F1)),xlim=c(max(F2.F1),min(F2.F1)),
    xlab = "F2-F1 (Hz)", ylab = "F1 (Hz)")
   data.ellipse(F2.F1[Vowel==vn[1]], F1[Vowel==vn[1]], levels=prob,
    col="black", lty=1, add=T, plot.points=F)
}

> (4) Does anybody else have problems getting "else" to work right? I
> always end up having to use a series of disjunctive "if"s....

I always do it like this:

if (<cond>) {
    ...
} else {
    ...
}

R might get confused if you put the "else" on a new line because line  
breaks may terminate R commands (unless they are obviously  
incomplete, which an "if" without "else" isn't).  It's a bit like  
Python in that respect ...

> (5) Is there any way to get R to print IPA in graphs? I suspect that
> there might be, at least on some platforms, though I'm sure the  
> process
> ain't pretty.

Get a Mac.  The GUI version of R for Mac OS X (aka R.app) plots  
(almost) any Unicode text, including the IPA extensions.

You may get to work this on other platforms, but you will probably  
have to fiddle with encodings and fonts to get everything right.

>
> (6) R documentation sucks.
>

I don't necessarily disagree with you, but which parts of the  
documentation are you referring to in particular?  The built-in HTML  
help?  The R tutorial?  The reference manual?  Any of the numerous  
text books on R that have appeared in recent years?

Best wishes,
Stefan





--
"Ecchi nanoha ikenai to omoimasu."
stefan.evert at uos.de
purl.org/stefan.evert




More information about the R-lang mailing list