Placement of attributes
Douglas Bates
bates@stat.wisc.edu
Mon, 23 Mar 1998 09:15:05 -0600 (CST)
In preparing data sets for the lme library, I bring the data into R,
convert it to the groupedData class, which is an extension of the
data.frame class, and use "dump" to create an R-readable version.
To cut down on the size of these files I convert the row.names
attribute from expressions like c("1", "2", ..., "54") to 1:54.
I have run into a curious problem that seems to related to the
position of the row.names attribute in the R-readable representation.
The following transcript was generated under R-0.61.1 on a Debian
Linux system. I apologize for the length of the transcript.
R> print.groupedData
function (x, ...)
{
cat("Grouped Data: ")
print(attr(x, "formula"))
NextMethod("print", x, ...)
}
R> "Machines" <-
+ structure(list
+ (Worker = structure(ordered(c(4, 4, 4, 2, 2, 2,
+ 5, 5, 5, 3, 3, 3, 6, 6, 6, 1, 1, 1, 4, 4, 4, 2, 2, 2, 5, 5, 5,
+ 3, 3, 3, 6, 6, 6, 1, 1, 1, 4, 4, 4, 2, 2, 2, 5, 5, 5, 3, 3, 3,
+ 6, 6, 6, 1, 1, 1), levels=1:6), class = c("ordered", "factor"),
+ .Label = c("6", "2", "4", "1", "3", "5")),
+ Machine = structure(factor(c(1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), levels=1:3), class = "factor",
+ .Label = c("A", "B", "C")),
+ score = c(52, 52.8,
+ 53.1, 51.8, 52.8, 53.1, 60, 60.2, 58.4, 51.1, 52.3, 50.3, 50.9,
+ 51.8, 51.4, 46.4, 44.8, 49.2, 62.1, 62.6, 64, 59.7, 60, 59, 68.6,
+ 65.8, 69.7, 63.2, 62.8, 62.2, 64.8, 65, 65.4, 43.7, 44.2, 43,
+ 67.5, 67.2, 66.9, 61.5, 61.7, 62.3, 70.8, 70.6, 71, 64.1, 66.2,
+ 64, 72.1, 72, 71.1, 62, 61.4, 60.5)),
+ class = c("nffGroupedData", "nfGroupedData", "groupedData", "data.frame"),
+ row.names = 1:54,
+ formula = score ~ 1 | Worker,
+ labels = list(y = "Productivity score"),
+ inner = ~ Machine)
R> Machines
Grouped Data: score ~ 1 | Worker
Worker Machine score
1 1 A 52.0
2 1 A 52.8
3 1 A 53.1
4 2 A 51.8
5 2 A 52.8
6 2 A 53.1
7 3 A 60.0
8 3 A 60.2
9 3 A 58.4
10 4 A 51.1
11 4 A 52.3
12 4 A 50.3
13 5 A 50.9
14 5 A 51.8
15 5 A 51.4
16 6 A 46.4
17 6 A 44.8
18 6 A 49.2
19 1 B 62.1
20 1 B 62.6
21 1 B 64.0
22 2 B 59.7
23 2 B 60.0
24 2 B 59.0
25 3 B 68.6
26 3 B 65.8
27 3 B 69.7
28 4 B 63.2
29 4 B 62.8
30 4 B 62.2
31 5 B 64.8
32 5 B 65.0
33 5 B 65.4
34 6 B 43.7
35 6 B 44.2
36 6 B 43.0
37 1 C 67.5
38 1 C 67.2
39 1 C 66.9
40 2 C 61.5
41 2 C 61.7
42 2 C 62.3
43 3 C 70.8
44 3 C 70.6
45 3 C 71.0
46 4 C 64.1
47 4 C 66.2
48 4 C 64.0
49 5 C 72.1
50 5 C 72.0
51 5 C 71.1
52 6 C 62.0
53 6 C 61.4
54 6 C 60.5
R> "Machines" <- # only change is position of "row.names" and "class" attributes
+ structure(list
+ (Worker = structure(ordered(c(4, 4, 4, 2, 2, 2,
+ 5, 5, 5, 3, 3, 3, 6, 6, 6, 1, 1, 1, 4, 4, 4, 2, 2, 2, 5, 5, 5,
+ 3, 3, 3, 6, 6, 6, 1, 1, 1, 4, 4, 4, 2, 2, 2, 5, 5, 5, 3, 3, 3,
+ 6, 6, 6, 1, 1, 1), levels=1:6), class = c("ordered", "factor"),
+ .Label = c("6", "2", "4", "1", "3", "5")),
+ Machine = structure(factor(c(1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), levels=1:3), class = "factor",
+ .Label = c("A", "B", "C")),
+ score = c(52, 52.8,
+ 53.1, 51.8, 52.8, 53.1, 60, 60.2, 58.4, 51.1, 52.3, 50.3, 50.9,
+ 51.8, 51.4, 46.4, 44.8, 49.2, 62.1, 62.6, 64, 59.7, 60, 59, 68.6,
+ 65.8, 69.7, 63.2, 62.8, 62.2, 64.8, 65, 65.4, 43.7, 44.2, 43,
+ 67.5, 67.2, 66.9, 61.5, 61.7, 62.3, 70.8, 70.6, 71, 64.1, 66.2,
+ 64, 72.1, 72, 71.1, 62, 61.4, 60.5)),
+ row.names = 1:54,
+ class = c("nffGroupedData", "nfGroupedData", "groupedData", "data.frame"),
+ formula = score ~ 1 | Worker,
+ labels = list(y = "Productivity score"),
+ inner = ~ Machine)
R> Machines
Grouped Data: score ~ 1 | Worker
Process R segmentation fault at Mon Mar 23 09:14:43 1998
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._