Discussion:
How do you take care of variable with missing values when plotting?
humphrey kimani
2018-07-27 14:00:06 UTC
Permalink
Hello,

I have a problem..

I have been plotting some data here..of gender( Female and Male).. you will
find in the data were missing gender.. when I am plotting eg a bar graph I
get 3 bar- I expected 2 but its graphing those with missing gender as a
variable...I don't want then to be included when am graphing.
Would any one help me how to go about it..

Regards

Humphrey & Lorine
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ron Crump
2018-07-27 15:00:02 UTC
Permalink
Hi Humphrey,
Post by humphrey kimani
I have a problem..
I have been plotting some data here..of gender( Female and Male).. you
will find in the data were missing gender.. when I am plotting eg a bar
graph I get 3 bar- I expected 2 but its graphing those with missing
gender as a variable...I don't want then to be included when am graphing.
Would any one help me how to go about it..
It would help us to help you if you could produce a small reproducible
example: data and code that illustrate the issue. Not neccesarily your
actual data, if that is private or overly large. The package 'reprex'
can help you ith this, but setting up some data including it via dput
in the email along with code that you've used on this data set would
help.

Regards,
Ron.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nabin Paudel
2018-07-27 15:47:14 UTC
Permalink
Hi,

This StackOverflow post may answer your query.

https://stackoverflow.com/questions/24344820/remove-missing-values-from-frequency-distributions-in-ggplot


Best Wishes,

Nabin
Post by Ron Crump
Hi Humphrey,
Post by humphrey kimani
I have a problem..
I have been plotting some data here..of gender( Female and Male).. you
will find in the data were missing gender.. when I am plotting eg a bar
graph I get 3 bar- I expected 2 but its graphing those with missing
gender as a variable...I don't want then to be included when am graphing.
Would any one help me how to go about it..
It would help us to help you if you could produce a small reproducible
example: data and code that illustrate the issue. Not neccesarily your
actual data, if that is private or overly large. The package 'reprex'
can help you ith this, but setting up some data including it via dput
in the email along with code that you've used on this data set would
help.
Regards,
Ron.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Nabin Paudel, PhD
Postdoctoral Researcher
Center for Eye Research Ireland
Dublin Institute of Technology, Dublin, Ireland
https://sites.google.com/view/drpaudel/
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Tom Fritzsche
2018-07-27 16:11:33 UTC
Permalink
Hi Humphrey & Lorine,

I believe ggplot will by default plot all levels of a factor including NAs.

To exclude the cases/lines with NAs for gender, do something like this
and then plot the new object.
This code assumes one data frame (df) with a column named 'gender'
where you coded FEMALE, MALE and have the NAs.

df2 <- df[!is.na(df$gender), ]

Hope this helps
Tom

---

Tom Fritzsche
University of Potsdam
Department of Linguistics
Karl-Liebknecht-Str. 24-25
14476 Potsdam
Germany

office: 14.140
phone: +49 331 977 2296
fax: +49 331 977 2095
email: ***@uni-potsdam.de
web: www.ling.uni-potsdam.de/~fritzsche
Post by humphrey kimani
Hello,
I have a problem..
I have been plotting some data here..of gender( Female and Male).. you will find in the data were missing gender.. when I am plotting eg a bar graph I get 3 bar- I expected 2 but its graphing those with missing gender as a variable...I don't want then to be included when am graphing.
Would any one help me how to go about it..
Regards
Humphrey & Lorine
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...