Comments (13)
Ok. Just a assume the code works perfectly in the template. I can improve it :)
from sitrep.
BLAM!
library("epireports")
set.seed(2018-01-15)
ages <- cut(sample(80, 150, replace = TRUE),
breaks = c(0, 5, 10, 30, 50, 80, 100), right = FALSE)
sex <- sample(c("Female", "Male"), 150, replace = TRUE)
ill <- sample(0:1, 150, replace = TRUE)
dat <- data.frame(AGE = ages, sex = sex, ill = ill, stringsAsFactors = FALSE)
datd <- dat[dat$AGE != levels(dat$AGE)[2], , drop = FALSE]
print(ap3 <- plot_age_pyramid(datd, age_group = "AGE"))
#> Warning: Removed 1 rows containing missing values (position_stack).
ap3$data
#> # A tibble: 10 x 4
#> # Groups: AGE [6]
#> AGE sex n .group
#> <fct> <chr> <int> <int>
#> 1 [0,5) Female -3 1
#> 2 [0,5) Male 3 1
#> 3 [5,10) <NA> NA 2
#> 4 [10,30) Female -22 3
#> 5 [10,30) Male 27 3
#> 6 [30,50) Female -16 4
#> 7 [30,50) Male 19 4
#> 8 [50,80) Female -24 5
#> 9 [50,80) Male 25 5
#> 10 [80,100) Female -4 6
Created on 2019-01-15 by the reprex package (v0.2.1)
from sitrep.
So dplyr apparently doesnt include factor levels with zero counts, must be some workaround but a quick google got me no-where. So say you have an over 80 age group and theres none in there - plot_age_pyramid will just show the group below that max age.
from sitrep.
Age pyramid works well - the issue of not including NA groups still there though (see two comments above). May also be good to include an option to change text size? @zkamvar
from sitrep.
The age pyramid code needs to be extended such that you can choose arbitrary groups for coloring. Currently it is by sex, but I have also seen by case definition
from sitrep.
@zkamvar is this something you can take a look at?
from sitrep.
ja!
from sitrep.
Age pyramid works well - the issue of not including NA groups still there though (see two comments above). May also be good to include an option to change text size? @zkamvar
I was able to get the NA groups to show up, though. Is it desireable to get something else?
library("epireports")
set.seed(2018-01-15)
ages <- cut(sample(80, 150, replace = TRUE),
breaks = c(0, 5, 10, 30, 70), right = FALSE)
sex <- sample(c("Female", "Male"), 150, replace = TRUE)
ill <- sample(0:1, 150, replace = TRUE)
dat <- data.frame(AGE = ages, sex = sex, ill = ill, stringsAsFactors = FALSE)
print(ap <- plot_age_pyramid(dat, age_group = "AGE"))
print(ap <- plot_age_pyramid(dat, age_group = "AGE", split_by = "ill"))
Created on 2019-01-15 by the reprex package (v0.2.1)
from sitrep.
ah nice!
And what if there is a factor level with zero counts? Cus I couldnt get that to work either....
from sitrep.
Ah! Still can't do that, but I'll see if I can give it a go
from sitrep.
Looks like it is good for now?
from sitrep.
Yep perfect!
Will eventually tinker with some aesthetic stuff like being able to not show the y-axis line. Showing horizontal dashed lines at each group and being able to mess with text size.
But for now is great as is
from sitrep.
I will close it. Feel free to open a new issue for specific things
from sitrep.
Related Issues (20)
- add data and dictionary validation
- surveys gtsummary wrapper HOT 1
- fix survey gtsummary::inline_text
- add msf_dict_rename_helper() to surveys HOT 1
- review zcurve() function
- add a decision tree overview of rmd structure
- discuss {rnssp-rmd-templates}
- fix {sitrep} re-exports HOT 1
- shift templates to quarto HOT 1
- move to r-universe
- update google analytics tags
- finalising {gtsummary} wrappers
- put geom_event() function in {epikit} HOT 1
- find_start_date defaults
- languages {pkgdown} website
- r-opensci package peer review
- add tests for data imports HOT 1
- tidyverse updates
- sitrep logo
- final steps
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sitrep.