[R] Removing NA in ggplot
Jeff Newmiller
jdnewmil at dcn.davis.ca.us
Sat Nov 6 15:23:42 CET 2010
Create a subset of your data that excludes the NAs before you feed it to ggplot.
"Ottar Kvindesland" <ottar.kvindesland at gmail.com> wrote:
>Hi list,
>
>I just got stuck with this one:
>
>In Data I have the sets age (numbers 1 to 99 and NA) and gender (M, F
>and
>NA). Then getting some nice plots using
>
>ggplot(data, aes(age[na.exclude(gender)])) +
>geom_histogram( binwidth = 3, aes(y = ..density.. ), fill = "lightblue"
>)
>+
> facet_grid( gender ~ .)
>
>I am trying to get a faceted graph of age distribution excluding the NA
>data
>for gender
>
>Unfortunately I end up with the error message:
>
>Error in data.frame(..., check.names = FALSE) :
>arguments imply differing number of rows: 206, 219
>
>How do i Wash out NA's in this situation?
>
>
>Regards
>
>ottar
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
More information about the R-help
mailing list