Skip to content

Commit

Permalink
Fixes for R CMD check
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Dec 11, 2008
1 parent ae149de commit ebf7878
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 23 deletions.
10 changes: 10 additions & 0 deletions R/date-time-breaks.r
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Time breaks
# Automatically compute sensible axis breaks for time data
#
# @arguments range in seconds
# @keyword internal
time_breaks <- function(seconds) {
days <- seconds / 86400
if (days > 5) {
Expand All @@ -17,6 +22,11 @@ time_breaks <- function(seconds) {

}

# Date breaks
# Automatically compute sensible axis breaks for date data
#
# @arguments range in days
# @keyword internal
date_breaks <- function(days) {
length <- cut(days, c(0, 10, 56, 365, 730, 5000, Inf), labels=FALSE)

Expand Down
12 changes: 7 additions & 5 deletions R/facet-wrap.r
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ FacetWrap <- proto(Facet, {
axes_h <- grobMatrix(axes_h, nrow, ncol, .$as.table)
axes_height <- grobRowHeight(axes_h)

all <- cweave(
rweave(gap, axes_v, gap, gap),
rweave(labels, panels, axes_h, gap),
rweave(gap, gap, gap, gap)
)
all <- rweave(
cweave(gap, labels, gap),
cweave(axes_v, panels, gap),
cweave(gap, axes_h, gap),
cweave(gap, gap, gap)
)

margin <- list(theme$panel.margin)
heights <- interleave(labels_height, panels_height, axes_height, margin)
heights <- do.call("unit.c", heights)
Expand Down
16 changes: 8 additions & 8 deletions R/fortify.r
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ fortify <- function(model, data, ...) UseMethod("fortify")
# The following statistics will be added to the data frame:
#
# \itemize{
# \item[.hat] Diagonal of the hat matrix
# \item[.sigma] Estimate of residual standard deviation when corresponding
# observation is dropped from model
# \item{.cooksd} Cooks distance, \code{\link{cooks.distance}}
# \item{.fitted} Fitted values of model
# \item{.resid} Residual
# \item{.stdresid} Standardised residuals
# \item{.hat}{Diagonal of the hat matrix}
# \item{.sigma}{Estimate of residual standard deviation when corresponding
# observation is dropped from model}
# \item{.cooksd}{Cooks distance, \code{\link{cooks.distance}}}
# \item{.fitted}{Fitted values of model}
# \item{.resid}{Residuals}
# \item{.stdresid}{Standardised residuals}
# }
#
# If you have missing values in your model data, you may need to refit
Expand Down Expand Up @@ -69,7 +69,7 @@ fortify.lm <- function(model, data = model$model, ...) {

data$.hat <- infl$hat
data$.sigma <- infl$sigma
data$.cooksd <- cooks.distance(mod)
data$.cooksd <- cooks.distance(model)

data$.fitted <- predict(model)
data$.resid <- resid(model)
Expand Down
5 changes: 3 additions & 2 deletions R/guides-legend.r
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ guide_legends_box <- function(scales, layers, default_mapping, horizontal = FALS
# @argument list description usage of aesthetics in geoms
# @keyword internal
# @value A list of grobs
#
# @alias build_legend
# @alias build_legend_data
#X theme_update(legend.background = theme_rect(size = 0.2))
#X qplot(mpg, wt, data = mtcars)
#X qplot(mpg, wt, data = mtcars, colour = cyl)
Expand Down Expand Up @@ -84,7 +85,7 @@ build_legend <- function(name, mapping, layers, default_mapping, theme) {
points <- laply(layers, function(l) l$geom$objname == "point")
width <- max(unlist(llply(legend_data[points], "[[", "size")), 0)

name <- eval(parse(text = name))
name <- eval(parse(text = name))
title <- theme_render(
theme, "legend.title",
name, x = 0, y = 0.5
Expand Down
1 change: 1 addition & 0 deletions R/labels.r
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ update_labels <- function(p, labels) {

for(name in names(labels)) {
scale <- p$scales$get_scales(name)$clone()
p$scales$add(scale)
scale$name <- labels[[name]]
}

Expand Down
6 changes: 2 additions & 4 deletions R/plot.r
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Create a new plot
# Create a new ggplot plot
#
# @alias package-ggplot
# @seealso \url{http://had.co.nz/ggplot2}
# @seealso ggplot.data.frame
# @alias ggplot.default
# @keyword hplot
ggplot <- function(data = NULL, ...) UseMethod("ggplot")

# Catch all plotting method
#
ggplot.default <- function(data, mapping = aes(), ...) {
if (is.null(data)) {
ggplot.data.frame(data, mapping, ...)
Expand All @@ -24,6 +21,7 @@ ggplot.default <- function(data, mapping = aes(), ...) {
# @arguments default data frame
# @arguments default list of aesthetic mappings (these can be colour, size, shape, line type -- see individual geom functions for more details)
# @seealso \url{http://had.co.nz/ggplot2}
# @alias package-ggplot
# @keyword hplot
ggplot.data.frame <- function(data, mapping=aes(), ..., environment = globalenv()) {
if (!missing(mapping) && !inherits(mapping, "uneval")) stop("Mapping should be created with aes or aes_string")
Expand Down
1 change: 0 additions & 1 deletion R/scale-date.r
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#
# * threshold for displaying first/last tick mark outside the data: if the last date point is > threshold * interval (default to 0.9)

TransDate <- Trans$new("date", "as.numeric", "to_date")
ScaleDate <- proto(ScaleContinuous,{
.major_seq <- NULL
.minor_seq <- NULL
Expand Down
5 changes: 4 additions & 1 deletion R/scale-datetime.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# To time
# Turn numeric vector into POSIXct vector
#
# @keyword internal
to_time <- function(x) structure(x, class = c("POSIXt", "POSIXct"))
TransDatetime <- Trans$new("datetime", "as.numeric", "to_time")

ScaleDatetime <- proto(ScaleDate, {
.major_seq <- NULL
Expand Down
2 changes: 1 addition & 1 deletion R/stat-smooth-methods.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# @keywords internal
# @alias predictdf.default
# @alias predictdf.glm
predictdf <- function(model, ...) UseMethod("predictdf")
predictdf <- function(model, xseq, se, level) UseMethod("predictdf")

predictdf.default <- function(model, xseq, se, level) {
pred <- stats::predict(model, data.frame(x = xseq), se = se)
Expand Down
1 change: 1 addition & 0 deletions R/theme-defaults.r
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ theme_bw <- function(base_size = 12) {

legend.background = theme_rect(colour=NA),
legend.key = theme_rect(colour = "grey80"),
legend.key.size = unit(1.2, "lines"),
legend.text = theme_text(size = base_size * 0.8),
legend.title = theme_text(size = base_size * 0.8, face = "bold", hjust = 0),
legend.position = "right",
Expand Down
5 changes: 4 additions & 1 deletion R/trans-.r
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,7 @@ TransLogit <- ProbabilityTrans$new("logis")
TransPow10 <- Trans$new("pow10",function(x) 10^x, "log10", function(x) log10(x))
TransProbit <- ProbabilityTrans$new("norm")
TransReverse <- Trans$new("reverse", function(x) -x, function(x) -x, function(x) bquote(.(-x)))
TransSqrt <- Trans$new("sqrt", "sqrt", function(x) x^2, function(x) x^2)
TransSqrt <- Trans$new("sqrt", "sqrt", function(x) x^2, function(x) x^2)

TransDate <- Trans$new("date", "as.numeric", "to_date")
TransDatetime <- Trans$new("datetime", "as.numeric", "to_time")

0 comments on commit ebf7878

Please sign in to comment.