Running examples in ‘agridat-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: gregory.cotton
> ### Title: Factorial experiment of cotton in Sudan.
> ### Aliases: gregory.cotton
> ### Keywords: datasets
> 
> ### ** Examples
> 
> 
> data(gregory.cotton)
> dat <- gregory.cotton
> 
> if(require(dplyr)){
+   # Main effect means, Gregory table 2
+   dat 
+   dat 
+   dat 
+   dat 
+ }
Loading required package: dplyr

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

    yield year nitrogen date water spacing
1    0.99   Y1       N0   D1    I1      S1
2    1.34   Y1       N0   D1    I1      S2
3    1.26   Y1       N0   D1    I1      S3
4    1.44   Y1       N0   D1    I2      S1
5    1.40   Y1       N0   D1    I2      S2
6    1.36   Y1       N0   D1    I2      S3
7    1.23   Y1       N0   D1    I3      S1
8    1.28   Y1       N0   D1    I3      S2
9    1.56   Y1       N0   D1    I3      S3
10   1.64   Y1       N0   D2    I1      S1
11   1.72   Y1       N0   D2    I1      S2
12   1.80   Y1       N0   D2    I1      S3
13   1.79   Y1       N0   D2    I2      S1
14   2.12   Y1       N0   D2    I2      S2
15   1.92   Y1       N0   D2    I2      S3
16   1.85   Y1       N0   D2    I3      S1
17   2.06   Y1       N0   D2    I3      S2
18   2.10   Y1       N0   D2    I3      S3
19   1.96   Y1       N0   D3    I1      S1
20   1.85   Y1       N0   D3    I1      S2
21   1.40   Y1       N0   D3    I1      S3
22   1.82   Y1       N0   D3    I2      S1
23   1.89   Y1       N0   D3    I2      S2
24   1.83   Y1       N0   D3    I2      S3
25   1.98   Y1       N0   D3    I3      S1
26   1.82   Y1       N0   D3    I3      S2
27   1.63   Y1       N0   D3    I3      S3
28   1.51   Y1       N0   D4    I1      S1
29   1.30   Y1       N0   D4    I1      S2
30   1.16   Y1       N0   D4    I1      S3
31   1.60   Y1       N0   D4    I2      S1
32   1.61   Y1       N0   D4    I2      S2
33   1.16   Y1       N0   D4    I2      S3
34   1.83   Y1       N0   D4    I3      S1
35   1.41   Y1       N0   D4    I3      S2
36   1.27   Y1       N0   D4    I3      S3
37   2.15   Y1       N1   D1    I1      S1
38   2.14   Y1       N1   D1    I1      S2
39   2.13   Y1       N1   D1    I1      S3
40   3.01   Y1       N1   D1    I2      S1
41   2.87   Y1       N1   D1    I2      S2
42   2.71   Y1       N1   D1    I2      S3
43   3.33   Y1       N1   D1    I3      S1
44   3.36   Y1       N1   D1    I3      S2
45   3.26   Y1       N1   D1    I3      S3
46   2.75   Y1       N1   D2    I1      S1
47   2.65   Y1       N1   D2    I1      S2
48   2.54   Y1       N1   D2    I1      S3
49   3.19   Y1       N1   D2    I2      S1
50   3.08   Y1       N1   D2    I2      S2
51   3.09   Y1       N1   D2    I2      S3
52   3.58   Y1       N1   D2    I3      S1
53   3.23   Y1       N1   D2    I3      S2
54   3.56   Y1       N1   D2    I3      S3
55   2.79   Y1       N1   D3    I1      S1
56   2.35   Y1       N1   D3    I1      S2
57   1.94   Y1       N1   D3    I1      S3
58   3.48   Y1       N1   D3    I2      S1
59   2.57   Y1       N1   D3    I2      S2
60   2.27   Y1       N1   D3    I2      S3
61   3.49   Y1       N1   D3    I3      S1
62   3.00   Y1       N1   D3    I3      S2
63   2.09   Y1       N1   D3    I3      S3
64   1.99   Y1       N1   D4    I1      S1
65   1.36   Y1       N1   D4    I1      S2
66   1.13   Y1       N1   D4    I1      S3
67   2.27   Y1       N1   D4    I2      S1
68   1.81   Y1       N1   D4    I2      S2
69   1.39   Y1       N1   D4    I2      S3
70   2.43   Y1       N1   D4    I3      S1
71   1.91   Y1       N1   D4    I3      S2
72   1.33   Y1       N1   D4    I3      S3
73   0.83   Y2       N0   D1    I1      S1
74   0.98   Y2       N0   D1    I1      S2
75   0.93   Y2       N0   D1    I1      S3
76   0.92   Y2       N0   D1    I2      S1
77   1.13   Y2       N0   D1    I2      S2
78   1.06   Y2       N0   D1    I2      S3
79   0.94   Y2       N0   D1    I3      S1
80   1.02   Y2       N0   D1    I3      S2
81   1.10   Y2       N0   D1    I3      S3
82   0.90   Y2       N0   D2    I1      S1
83   1.08   Y2       N0   D2    I1      S2
84   1.06   Y2       N0   D2    I1      S3
85   1.20   Y2       N0   D2    I2      S1
86   1.09   Y2       N0   D2    I2      S2
87   1.17   Y2       N0   D2    I2      S3
88   1.08   Y2       N0   D2    I3      S1
89   1.10   Y2       N0   D2    I3      S2
90   1.08   Y2       N0   D2    I3      S3
91   0.95   Y2       N0   D3    I1      S1
92   0.99   Y2       N0   D3    I1      S2
93   0.91   Y2       N0   D3    I1      S3
94   0.97   Y2       N0   D3    I2      S1
95   1.21   Y2       N0   D3    I2      S2
96   1.18   Y2       N0   D3    I2      S3
97   1.10   Y2       N0   D3    I3      S1
98   1.01   Y2       N0   D3    I3      S2
99   0.90   Y2       N0   D3    I3      S3
100  0.87   Y2       N0   D4    I1      S1
101  0.90   Y2       N0   D4    I1      S2
102  0.77   Y2       N0   D4    I1      S3
103  1.08   Y2       N0   D4    I2      S1
104  0.85   Y2       N0   D4    I2      S2
105  0.70   Y2       N0   D4    I2      S3
106  0.96   Y2       N0   D4    I3      S1
107  0.77   Y2       N0   D4    I3      S2
108  0.67   Y2       N0   D4    I3      S3
109  1.77   Y2       N1   D1    I1      S1
110  1.73   Y2       N1   D1    I1      S2
111  1.40   Y2       N1   D1    I1      S3
112  1.76   Y2       N1   D1    I2      S1
113  2.04   Y2       N1   D1    I2      S2
114  1.77   Y2       N1   D1    I2      S3
115  2.05   Y2       N1   D1    I3      S1
116  1.94   Y2       N1   D1    I3      S2
117  1.90   Y2       N1   D1    I3      S3
118  1.71   Y2       N1   D2    I1      S1
119  1.86   Y2       N1   D2    I1      S2
120  1.79   Y2       N1   D2    I1      S3
121  2.32   Y2       N1   D2    I2      S1
122  2.14   Y2       N1   D2    I2      S2
123  2.03   Y2       N1   D2    I2      S3
124  2.50   Y2       N1   D2    I3      S1
125  2.38   Y2       N1   D2    I3      S2
126  2.07   Y2       N1   D2    I3      S3
127  1.57   Y2       N1   D3    I1      S1
128  1.63   Y2       N1   D3    I1      S2
129  1.23   Y2       N1   D3    I1      S3
130  2.04   Y2       N1   D3    I2      S1
131  1.95   Y2       N1   D3    I2      S2
132  1.63   Y2       N1   D3    I2      S3
133  2.48   Y2       N1   D3    I3      S1
134  1.99   Y2       N1   D3    I3      S2
135  1.46   Y2       N1   D3    I3      S3
136  1.21   Y2       N1   D4    I1      S1
137  1.14   Y2       N1   D4    I1      S2
138  1.02   Y2       N1   D4    I1      S3
139  1.47   Y2       N1   D4    I2      S1
140  1.25   Y2       N1   D4    I2      S2
141  0.93   Y2       N1   D4    I2      S3
142  1.52   Y2       N1   D4    I3      S1
143  1.21   Y2       N1   D4    I3      S2
144  0.92   Y2       N1   D4    I3      S3
> 
> # Figure 2 of Gregory. Not recommended, but an interesting exercise.
> # http://stackoverflow.com/questions/13887365
> if(require(ggplot2)){
+   d1 <- subset(dat, year=="Y1")
+   d1 <- transform(d1, grp=factor(paste(date,nitrogen,water,spacing)))
+   d1 <- d1[order(d1$grp),] # for angles
+   # Rotate labels on the left half 180 deg. First 18, last 18 labels
+   d1$ang <- 90+seq(from=(360/nrow(d1))/1.5, to=(1.5*(360/nrow(d1)))-360,
+                    length.out=nrow(d1))+80
+   d1$ang[1:18] <- d1$ang[1:18] + 180
+   d1$ang[55:72] <- d1$ang[55:72] + 180
+   # Lables on left half to right-adjusted
+   d1$hjust <- 0
+   d1$hjust[1:18] <- d1$hjust[55:72] <- 1
+   
+   gg <- ggplot(d1, aes(x=grp,y=yield,fill=factor(spacing))) +
+     geom_col() +
+     guides(fill=FALSE) + # no legend for 'spacing'
+     coord_polar(start=-pi/2) + # default is to start at top
+     labs(title="gregory.cotton 1929",x="",y="",label="") +
+     # The bar columns are centered on 1:72, subtract 0.5 to add radial axes
+     geom_vline(xintercept = seq(1, 72, by=3)-0.5, color="gray", size=.25) +
+     geom_vline(xintercept = seq(1, 72, by=18)-0.5, size=1) +
+     geom_vline(xintercept = seq(1, 72, by=9)-0.5, size=.5) +
+     geom_hline(yintercept=c(1,2,3)) + 
+     geom_text(data=d1, aes(x=grp, y=max(yield), label=grp, angle=ang, hjust=hjust),
+               size=2) +
+     theme(panel.background=element_blank(),
+           axis.title=element_blank(),
+           panel.grid=element_blank(),
+           axis.text.x=element_blank(),
+           axis.text.y=element_blank(),
+           axis.ticks=element_blank() )
+   print(gg)
+   
+ }
Loading required package: ggplot2
Error in grid.Call.graphics(C_setviewport, vp, TRUE) : 
  VECTOR_ELT() can only be applied to a 'list', not a 'double'
Calls: print ... lapply -> FUN -> push.vp.viewport -> grid.Call.graphics
Execution halted