ggplot_build-na.keep

12 views
Skip to first unread message

Felipe Carrillo

unread,
Mar 6, 2013, 3:25:51 PM3/6/13
to ggp...@googlegroups.com
HI,
How can I have ggplot_build keep NA's
please consider the dummy dataset below. ggplot_build() removes two records
due to NA's but I would like to keep them.
 
mydata <- structure(list(IDDate = structure(1:14, .Label = c("7/23/2007",
"7/24/2007", "7/25/2007", "7/26/2007", "7/27/2007", "7/28/2007",
"7/29/2007", "7/30/2007", "7/31/2007", "8/1/2007", "8/2/2007",
"8/3/2007", "8/4/2007", "8/5/2007"), class = "factor"), mean_daily_flows = c(28147L,
27856L, 28088L, 27939L, 27798L, 26454L, 24522L, 24837L, 24839L,
24758L, 24220L, 24823L, 24770L, 24778L), flows_sampled = c(573.262,
537.761, 554.885, 541.093, 511.332, 397.501, 521.744, 518.01,
513.138, 380.227, 545.376, 534.864, 553.226, 518.825), percent_flows_sampled = c(0.020367,
0.019305, 0.019755, 0.019367, 0.018395, 0.015026, 0.021277, 0.020856,
0.020659, 0.015358, 0.022518, 0.021547, 0.022335, 0.020939),
    measured_fish = c(11L, 15L, 15L, 11L, 6L, 3L, 3L, 9L, 9L,
    6L, 9L, 15L, 13L, 21L)), .Names = c("IDDate", "mean_daily_flows",
"flows_sampled", "percent_flows_sampled", "measured_fish"), class = "data.frame", row.names = c(NA,
-14L))
mydata
mydata[c(7,14),5] <- NA
test <- ggplot(mydata,aes(IDDate,measured_fish)) + geom_point()
test <- test + geom_smooth(aes(group=1),size=1,colour='red')  
x <- ggplot_build(test)$data      # Dont remove NA's
x
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA
Reply all
Reply to author
Forward
0 new messages