From d41339d3e160bd2e08cf69f82a2ec18f8735eb5a Mon Sep 17 00:00:00 2001
From: Walmes Zeviani <walmes@ufpr.br>
Date: Thu, 8 Oct 2015 11:10:22 -0300
Subject: [PATCH] Format the structure() of each dataset.

---
 data-raw/bib1.R     | 80 ++++++++++++++++++++++++++++++++-------------
 data-raw/bib2.R     | 47 ++++++++++++++++----------
 data-raw/bib3.R     | 33 ++++++++++++-------
 data-raw/bib3asin.R | 46 ++++++++++++++++----------
 4 files changed, 136 insertions(+), 70 deletions(-)

diff --git a/data-raw/bib1.R b/data-raw/bib1.R
index 9688a6b..00c7ae8 100644
--- a/data-raw/bib1.R
+++ b/data-raw/bib1.R
@@ -6,46 +6,82 @@
 ## bib1 <- transform(bib1, rept=factor(rept),
 ##                   block=factor(block), treat=factor(treat))
 
-bib1 <- 
-structure(list(rept = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
-1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
-3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
-5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
-7L), .Label = c("1", "2", "3", "4", "5", "6", "7"), class = "factor"), 
-    treat = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 3L, 
-    2L, 8L, 4L, 5L, 6L, 7L, 1L, 4L, 2L, 7L, 3L, 6L, 5L, 8L, 1L, 
-    5L, 2L, 3L, 4L, 7L, 6L, 8L, 1L, 6L, 2L, 4L, 3L, 8L, 5L, 7L, 
-    1L, 7L, 2L, 6L, 3L, 5L, 4L, 8L, 1L, 8L, 2L, 5L, 3L, 7L, 4L, 
-    6L), .Label = c("1", "2", "3", "4", "5", "6", "7", "8"), class = "factor"), 
-    block = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 
-    2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 
-    1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 
-    1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 
-    4L), .Label = c("1", "2", "3", "4"), class = "factor"), y = c(20L, 
-    18L, 15L, 16L, 14L, 15L, 16L, 18L, 24L, 18L, 25L, 19L, 13L, 
-    16L, 12L, 16L, 23L, 17L, 26L, 18L, 15L, 17L, 13L, 16L, 21L, 
-    13L, 23L, 16L, 10L, 12L, 13L, 11L, 28L, 14L, 27L, 18L, 18L, 
-    15L, 16L, 17L, 22L, 17L, 24L, 16L, 18L, 14L, 15L, 17L, 23L, 
-    15L, 21L, 13L, 15L, 12L, 13L, 16L)), .Names = c("rept", "treat", 
-"block", "y"), row.names = c(NA, -56L), class = "data.frame")
+bib1 <- structure(list(
+    rept = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
+                       2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
+                       4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L,
+                       5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
+                       7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L),
+                     .Label = c("1", "2", "3", "4", "5", "6", "7"),
+                     class = "factor"),
+    treat = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 3L, 2L, 8L,
+                        4L, 5L, 6L, 7L, 1L, 4L, 2L, 7L, 3L, 6L, 5L, 8L,
+                        1L, 5L, 2L, 3L, 4L, 7L, 6L, 8L, 1L, 6L, 2L, 4L,
+                        3L, 8L, 5L, 7L, 1L, 7L, 2L, 6L, 3L, 5L, 4L, 8L,
+                        1L, 8L, 2L, 5L, 3L, 7L, 4L,
+                        6L),
+                      .Label = c("1", "2", "3", "4", "5", "6", "7",
+                                 "8"),
+                      class = "factor"),
+    block = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L,
+                        3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L,
+                        1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L,
+                        3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L,
+                        1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L),
+                      .Label = c("1", "2", "3", "4"),
+                      class = "factor"),
+    y = c(20L, 18L, 15L, 16L, 14L, 15L, 16L, 18L, 24L,
+          18L, 25L, 19L, 13L, 16L, 12L, 16L, 23L, 17L,
+          26L, 18L, 15L, 17L, 13L, 16L, 21L, 13L, 23L,
+          16L, 10L, 12L, 13L, 11L, 28L, 14L, 27L, 18L,
+          18L, 15L, 16L, 17L, 22L, 17L, 24L, 16L, 18L,
+          14L, 15L, 17L, 23L, 15L, 21L, 13L, 15L, 12L,
+          13L, 16L)),
+          .Names = c("rept", "treat", "block", "y"),
+          row.names = c(NA, -56L),
+          class = "data.frame")
 
+npk <- expand.grid(N=c(-1,1), P=c(-1,1), K=c(-1,1))
+npk$treat <- c(4,5,3,7,8,6,2,1)
+
+bib1 <- merge(npk, bib1)
+bib1$treat <- factor(bib1$treat)
 str(bib1)
 
+bib1 <- bib1[, c(5:6, 1:4, 7)]
+
 bib <- bib1[with(bib1, order(rept, block, treat)), ]
 
 save(bib1, file="../data/bib1.RData")
 
+##----------------------------------------------------------------------
+
+m0 <- aov(terms(y~rept/block+treat, keep.order=TRUE), data=bib1)
+anova(m0)
+
+library(doBy)
+LSmeans(m0, effect="treat")
+
+m1 <- aov(terms(y~rept/block+N*P*K, keep.order=TRUE), data=bib1)
+anova(m1)
+
 ##----------------------------------------------------------------------
 ## Examples.
 
 require(lattice)
 
+data(bib1)
+str(bib1)
+
 xyplot(y~treat|rept, groups=block, data=bib1, type="b",
        ylab="Y", xlab="Treatment")
 
 xyplot(y~treat, data=bib1, jitter.x=TRUE,
        ylab="Y", xlab="Treatment")
 
+xyplot(y~N|P+K, groups=rept, data=bib1, type="b",
+       ylab="Y", xlab="Nitrogen")
+
 rm(list=ls())
 load("../data/bib1.RData")
 ls()
diff --git a/data-raw/bib2.R b/data-raw/bib2.R
index 9fd0903..ed0692d 100644
--- a/data-raw/bib2.R
+++ b/data-raw/bib2.R
@@ -8,24 +8,32 @@
 ##                   block=factor(block), treat=factor(treat))
 ## dput(bib2)
 
-bib2 <- 
-structure(list(rept = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
-1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
-2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
-3L, 3L, 3L), .Label = c("1", "2", "3"), class = "factor"), block = structure(c(1L, 
-1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 1L, 1L, 2L, 
-2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 1L, 1L, 2L, 2L, 3L, 
-3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L), .Label = c("1", "2", "3", 
-"4", "5", "6", "7"), class = "factor"), treat = structure(c(1L, 
-2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 1L, 1L, 3L, 3L, 
-5L, 5L, 7L, 7L, 2L, 2L, 4L, 4L, 6L, 6L, 1L, 1L, 4L, 4L, 7L, 7L, 
-3L, 3L, 6L, 6L, 2L, 2L, 5L, 5L, 1L), .Label = c("1", "2", "3", 
-"4", "5", "6", "7"), class = "factor"), y = c(3.5, 2.8, 3.2, 
-3.7, 3.5, 2.5, 2.8, 2.7, 3, 3.2, 2.4, 2.6, 3.1, 2.7, 3.8, 4, 
-3.6, 2.7, 2.3, 3, 2.8, 2.5, 2.6, 2.8, 2.3, 2.4, 2.8, 3.3, 3, 
-2.2, 2.7, 3.4, 3.2, 3.9, 3.3, 2.4, 2.8, 3.4, 2.9, 2.6, 2.3, 3.3
-)), .Names = c("rept", "block", "treat", "y"), row.names = c(NA, 
--42L), class = "data.frame")
+bib2 <- structure(list(
+    rept = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
+                       1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,  2L,
+                       2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
+                       3L, 3L, 3L, 3L, 3L, 3L),
+                     .Label = c("1", "2", "3"), class = "factor"),
+    block = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L,
+                        7L, 7L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L,
+                        6L, 6L, 7L, 7L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L,
+                        5L, 5L, 6L, 6L, 7L, 7L),
+                      .Label = c("1", "2", "3", "4", "5", "6", "7"),
+                      class = "factor"),
+    treat = structure(c(1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L,
+                        7L, 1L, 1L, 3L, 3L, 5L, 5L, 7L, 7L, 2L, 2L, 4L,
+                        4L, 6L, 6L, 1L, 1L, 4L, 4L, 7L, 7L, 3L, 3L, 6L,
+                        6L, 2L, 2L, 5L, 5L, 1L),
+                      .Label = c("1", "2", "3", "4", "5", "6", "7"),
+                      class = "factor"),
+    y = c(3.5, 2.8, 3.2, 3.7, 3.5, 2.5, 2.8, 2.7, 3, 3.2, 2.4, 2.6, 3.1,
+          2.7, 3.8, 4, 3.6, 2.7, 2.3, 3, 2.8, 2.5, 2.6, 2.8, 2.3, 2.4,
+          2.8, 3.3, 3, 2.2, 2.7, 3.4, 3.2, 3.9, 3.3, 2.4, 2.8, 3.4, 2.9,
+          2.6, 2.3, 3.3)),
+          .Names = c("rept", "block", "treat", "y"),
+          row.names = c(NA, -42L),
+          class = "data.frame")
+
 str(bib2)
 
 bib <- bib2[with(bib2, order(rept, block, treat)), ]
@@ -37,6 +45,9 @@ save(bib2, file="../data/bib2.RData")
 
 require(lattice)
 
+data(bib2)
+str(bib2)
+
 xyplot(y~treat|rept, groups=block, data=bib2, type="b",
        ylab="Y", xlab="Treatment")
 
diff --git a/data-raw/bib3.R b/data-raw/bib3.R
index a5d9207..f708996 100644
--- a/data-raw/bib3.R
+++ b/data-raw/bib3.R
@@ -7,18 +7,24 @@
 ##                   block=factor(block), treat=factor(treat))
 ## dput(bib3)
 
-bib3 <-
-structure(list(block = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 
-3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 8L, 8L, 
-8L, 9L, 9L, 9L, 10L, 10L, 10L), .Label = c("1", "2", "3", "4", 
-"5", "6", "7", "8", "9", "10"), class = "factor"), treat = structure(c(1L, 
-2L, 3L, 1L, 2L, 4L, 1L, 2L, 5L, 1L, 3L, 4L, 1L, 3L, 5L, 1L, 4L, 
-5L, 2L, 3L, 4L, 2L, 3L, 5L, 2L, 4L, 5L, 3L, 4L, 5L), .Label = c("1", 
-"2", "3", "4", "5"), class = "factor"), y = c(35L, 28L, 27L, 
-30L, 20L, 22L, 28L, 16L, 18L, 36L, 29L, 30L, 29L, 19L, 22L, 25L, 
-16L, 19L, 26L, 30L, 28L, 27L, 29L, 27L, 29L, 29L, 27L, 27L, 26L, 
-29L)), .Names = c("block", "treat", "y"), row.names = c(NA, -30L
-), class = "data.frame")
+bib3 <- structure(list(
+    block = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L,
+                        5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 8L, 8L, 8L,
+                        9L, 9L, 9L, 10L, 10L, 10L),
+                      .Label = c("1", "2", "3", "4", "5", "6", "7", "8",
+                                 "9", "10"),
+                      class = "factor"),
+    treat = structure(c(1L, 2L, 3L, 1L, 2L, 4L, 1L, 2L, 5L, 1L, 3L, 4L,
+                        1L, 3L, 5L, 1L, 4L, 5L, 2L, 3L, 4L, 2L, 3L, 5L,
+                        2L, 4L, 5L, 3L, 4L, 5L),
+                      .Label = c("1", "2", "3", "4", "5"),
+                      class = "factor"),
+    y = c(35L, 28L, 27L, 30L, 20L, 22L, 28L, 16L, 18L, 36L, 29L, 30L,
+          29L, 19L, 22L, 25L, 16L, 19L, 26L, 30L, 28L, 27L, 29L, 27L,
+          29L, 29L, 27L, 27L, 26L, 29L)),
+          .Names = c("block", "treat", "y"),
+          row.names = c(NA, -30L),
+          class = "data.frame")
 
 bib <- bib3[with(bib3, order(block, treat)), ]
 
@@ -29,6 +35,9 @@ save(bib3, file="../data/bib3.RData")
 
 require(lattice)
 
+data(bib3)
+str(bib3)
+
 xyplot(y~treat|block, data=bib3,
        ylab="Y",
        xlab="Treatment")
diff --git a/data-raw/bib3asin.R b/data-raw/bib3asin.R
index 1f771d1..fc6873e 100644
--- a/data-raw/bib3asin.R
+++ b/data-raw/bib3asin.R
@@ -8,24 +8,31 @@
 ##                       block=factor(block), treat=factor(treat))
 ## dput(bib3asin)
 
-bib3asin <-
-structure(list(block = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 
-8L, 9L, 10L, 11L, 12L, 13L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
-10L, 11L, 12L, 13L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 
-11L, 12L, 13L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
-12L, 13L), .Label = c("1", "2", "3", "4", "5", "6", "7", "8", 
-"9", "10", "11", "12", "13"), class = "factor"), treat = structure(c(1L, 
-2L, 1L, 3L, 4L, 1L, 2L, 1L, 6L, 3L, 5L, 4L, 2L, 2L, 8L, 7L, 4L, 
-8L, 3L, 3L, 5L, 10L, 7L, 9L, 5L, 6L, 4L, 12L, 11L, 6L, 9L, 9L, 
-5L, 6L, 11L, 8L, 10L, 7L, 7L, 10L, 13L, 12L, 12L, 11L, 13L, 11L, 
-8L, 13L, 10L, 12L, 13L, 9L), .Label = c("1", "2", "3", "4", "5", 
-"6", "7", "8", "9", "10", "11", "12", "13"), class = "factor"), 
-    z = c(52.7, 71.6, 58.9, 75, 71.6, 56.8, 75, 48.8, 63.4, 71.6, 
-    75, 63.4, 71.6, 79.5, 56.8, 75, 65.9, 75, 65.9, 65.9, 68.6, 
-    90, 63.4, 68.6, 61.1, 63.4, 63.4, 71.6, 75, 79.5, 71.6, 71.6, 
-    65.9, 63.4, 90, 61.1, 75, 50.8, 61.1, 65.9, 65.9, 71.6, 79.5, 
-    79.5, 65.9, 90, 61.1, 71.6, 58.9, 75, 79.5, 75)), .Names = c("block", 
-"treat", "z"), row.names = c(NA, -52L), class = "data.frame")
+bib3asin <- structure(list(
+    block = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
+                        12L, 13L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
+                        10L, 11L, 12L, 13L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
+                        8L, 9L, 10L, 11L, 12L, 13L, 1L, 2L, 3L, 4L, 5L,
+                        6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L),
+                      .Label = c("1", "2", "3", "4", "5", "6", "7", "8",
+                                 "9", "10", "11", "12", "13"),
+                      class = "factor"),
+    treat = structure(c(1L, 2L, 1L, 3L, 4L, 1L, 2L, 1L, 6L, 3L, 5L, 4L,
+                        2L, 2L, 8L, 7L, 4L, 8L, 3L, 3L, 5L, 10L, 7L, 9L,
+                        5L, 6L, 4L, 12L, 11L, 6L, 9L, 9L, 5L, 6L, 11L,
+                        8L, 10L, 7L, 7L, 10L, 13L, 12L, 12L, 11L, 13L,
+                        11L, 8L, 13L, 10L, 12L, 13L, 9L),
+                      .Label = c("1", "2", "3", "4", "5", "6", "7", "8",
+                                 "9", "10", "11", "12", "13"),
+                      class = "factor"),
+    z = c(52.7, 71.6, 58.9, 75, 71.6, 56.8, 75, 48.8, 63.4, 71.6, 75,
+          63.4, 71.6, 79.5, 56.8, 75, 65.9, 75, 65.9, 65.9, 68.6, 90,
+          63.4, 68.6, 61.1, 63.4, 63.4, 71.6, 75, 79.5, 71.6, 71.6,
+          65.9, 63.4, 90, 61.1, 75, 50.8, 61.1, 65.9, 65.9, 71.6, 79.5,
+          79.5, 65.9, 90, 61.1, 71.6, 58.9, 75, 79.5, 75)),
+          .Names = c("block", "treat", "z"),
+          row.names = c(NA, -52L),
+          class = "data.frame")
 
 bib <- bib3asin[with(bib3asin, order(block, treat)), ]
 
@@ -36,6 +43,9 @@ save(bib3asin, file="../data/bib3asin.RData")
 
 require(lattice)
 
+data(bib3asin)
+str(bib3asin)
+
 xyplot(z~treat|block, data=bib3asin,
        ylab="Arc sin of heathy plants fraction",
        xlab="Treatment")
-- 
GitLab