This says thatloallactually hastwoclasses:"glm"and"lm". This is
because the"glm"class is a subclass of"lm". We’ll discuss classes in detail
in Chapter 9.
5.4.3 Extended Example: Aids for Learning Chinese Dialects.............
Standard Chinese, often referred to as Mandarin outside China, is officially
termedputonghuaorguoyu. It is spoken today by the vast majority of people
in China and among many ethnic Chinese outside China, but the dialects,
such as Cantonese and Shanghainese, still enjoy wide usage too. Thus, a Chi-
nese businessman in Beijing who intends to do business in Hong Kong may
find it helpful to learn some Cantonese. Similarly, many in Hong Kong may
wish to improve their Mandarin. Let’s see how such a learning process might
be shortened and how R can help.
The differences among the dialects are sometimes startling. The charac-
ter for “down,”下, is pronouncedxiain Mandarin,hain Cantonese, andwu
in Shanghainese. Indeed, because of these differences, and differences in
grammar as well, many linguists consider these tongues separate languages
rather than dialects. We will call themfangyan(meaning “regional speech”)
here, the Chinese term.
Let’s see how R can help speakers of one fangyan learn another one.
The key is that there are often patterns in the correspondences between the
fangyans. For instance, the initial consonant transformationx→hseen in
下in the previous paragraph (xia→ha) is common, arising also in charac-
ters such as香(meaning “fragrant”), pronouncedxiangin Mandarin and
heungin Cantonese. Note, too, the transformationiang→eungfor the non–
initial consonant portions of these pronounciations, which is also common.
Knowing transformations such as these could speed up the learning curve
considerably for the Mandarin-speaking learner of Cantonese, which is the
setting we’ll illustrate here.
We haven’t mentioned the tones yet. All the fangyan are tonal, and
sometimes there are patterns there as well, potentially providing further
learning aids. However, this avenue will not be pursued here. You’ll see that
our code does need to make some use of the tones, but we will not attempt
to analyze how tones transform from one fangyan to another. For simplicity,
we also will not consider characters beginning with vowels, characters that
have more than one reading, toneless characters, and other refinements.
Though the initial consonantxin Mandarin often maps toh, as seen
previously, it also often maps tos,y, and other consonants. For example,
the characterxie,謝, in the famous Mandarin termxiexie(for “thank you”)
is pronouncedjein Cantonese. Here, there is anx→jtransformation on
the consonant.
It would be very helpful for the learner to have a list of transformations
and their frequencies of occurrence. This a job made for R! The function
mapsound(), shown a little later in the chapter, does exactly this. It relies on
some support functions, also to be presented shortly.
Data Frames 115