The Art of R Programming
This says thatloallactually hastwoclasses:"glm"and"lm". This is because the"glm"class is a subclass of"lm". We’ll discuss classe ...
To explain whatmapsound()does, let’s devise some terminology, illus- trated by thex→hexample earlier. We’ll callxthesource value ...
That information is stored inimages. The latter, as mentioned, is a list of vec- tors. We are interested in the vector correspon ...
7 # 2, and tones in row 3 8 saplout <- sapply((fy[[2]]),sepsoundtone) 9 # convert it to a data frame 10 tmpdf <- data.fram ...
The actual separation into sound components is done in line 8. Here, we take a column of romanizations, such the following: yat1 ...
Recall that the argumentdfis the two-fangyan data frame, output from merge2fy(). The argumentsfromcolandtocolare the names of th ...
6 FACTORS AND TABLES Factors form the basis for many of R’s powerful operations, including many of those performed on tabular da ...
>xf [1]5 121312 Levels: 5 12 13 The distinct values inxf—5, 12, and 13—are the levels here. Let’s take a look inside: > st ...
6.2 Common Functions Used with Factors......................................... With factors, we have yet another member of the ...
finding mean income, broken down by gender and age. If we setg()to be mean(),tapply()will return the mean incomes in each of fou ...
into groups, which are returned in a list. (Note thatxis allowed to be a data frame withsplit()but not withtapply().) Let’s try ...
Let’s dissect this step-by-step. The vectorg, taken as a factor, has three levels:"M","F", and"I". The indices corresponding to ...
Call: lm(formula = m[, 2] ~ m[, 3]) Coefficients: (Intercept) m[, 3] 0.04288 1.17918 ------------------------------------------- ...
12 1 1 13 2 1 Here,tapply()again temporarily breaksuinto subvectors, as you saw ear- lier, and then applies thelength()function ...
Vote.for.X Voted.for.X.Last.Time 1 Yes Yes 2 Yes No 3No No 4 Not Sure Yes 5No No We can use thetable()function to compute the co ...
race genderABOW F1100 M0000 ,,pol=L race genderABOW F0100 M0012 R prints out a three-dimensional table as a series of two-dimens ...
In statistics, themarginalvalues of a variable are those obtained when this variable is held constant while others are summed. I ...
Suppose we wish to present this data at a meeting, concentrating on those respondents who know they will vote for X in the curre ...
9 for (i in 1:ndims) { 10 dcargs[[i+1]] <- subnames[[i]] 11 } 12 subarray <- do.call("[",dcargs) 13 # now we'll build the ...
This makes it easy to call a function with a variable number of arguments. For our example, we need to form a list consisting fi ...
«
3
4
5
6
7
8
9
10
11
12
»
Free download pdf