@@ -5,10 +5,8 @@ collide <- function(data, width = NULL, name, strategy, check.width = TRUE) {
5
5
if (! is.null(width )) {
6
6
# Width set manually
7
7
if (! (all(c(" xmin" , " xmax" ) %in% names(data )))) {
8
- data <- within(data , {
9
- xmin <- x - width / 2
10
- xmax <- x + width / 2
11
- })
8
+ data $ xmin <- data $ x - width / 2
9
+ data $ xmax <- data $ x - width / 2
12
10
}
13
11
} else {
14
12
if (! (all(c(" xmin" , " xmax" ) %in% names(data )))) {
@@ -17,7 +15,7 @@ collide <- function(data, width = NULL, name, strategy, check.width = TRUE) {
17
15
}
18
16
19
17
# Width determined from data, must be floating point constant
20
- widths <- unique(with( data , xmax - xmin ) )
18
+ widths <- unique(data $ xmax - data $ xmin )
21
19
widths <- widths [! is.na(widths )]
22
20
if (! zero_range(range(widths ))) {
23
21
warning(name , " requires constant width: output may be incorrect" ,
@@ -41,13 +39,14 @@ collide <- function(data, width = NULL, name, strategy, check.width = TRUE) {
41
39
}
42
40
43
41
if (! is.null(data $ ymax )) {
44
- ddply(data , .( xmin ) , strategy , width = width )
42
+ ddply(data , " xmin" , strategy , width = width )
45
43
} else if (! is.null(data $ y )) {
46
44
message(" ymax not defined: adjusting position using y instead" )
47
- transform(
48
- ddply(transform(data , ymax = y ), .(xmin ), strategy , width = width ),
49
- y = ymax
50
- )
45
+
46
+ data $ ymax <- data $ y
47
+ data <- ddply(data , " xmin" , strategy , width = width )
48
+ data $ y <- data $ ymax
49
+ data
51
50
} else {
52
51
stop(" Neither y nor ymax defined" )
53
52
}
0 commit comments