Skip to content

Commit

Permalink
Allow empty data frame while passing in vectors for aesthetics
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Apr 18, 2012
1 parent 989dbfe commit 946b136
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion R/layer.r
Expand Up @@ -161,7 +161,19 @@ Layer <- proto(expr = {

if (length(evaled) == 0) return(data.frame(PANEL = unique(data$PANEL)))
# evaled <- evaled[sapply(evaled, is.atomic)]
data.frame(evaled, PANEL = data$PANEL)

if (empty(data)) {
if (length(evaled[[1]]) == 0) {
# No data and no vector of values for aesthetics
return(data.frame(PANEL = numeric(0)))
} else {
# No data but with a vector passed to aesthetics, as in qplot(1:3, 1:3)
return(data.frame(evaled, PANEL = 1))
}
}
else {
return(data.frame(evaled, PANEL = data$PANEL))
}
}


Expand Down

0 comments on commit 946b136

Please sign in to comment.