csu_trendCohortPeriod {Rcan} | R Documentation |
csu_trendCohortPeriod
Description
csu_trendCohortPeriod
plot cohort period age specific graph.
Usage
csu_trendCohortPeriod(
df_data,
var_age = "age",
var_cases="cases",
var_py="py",
var_year = "year",
type = "Cohort",
missing_age = NULL,
logscale = TRUE,
db_rate = 100000,
first_age = 6,
last_age = 16,
year_group = 5,
age_dropped=FALSE,
plot_title = "csu_title",
format_export = NULL,
graph_dev =FALSE)
Arguments
df_data |
Data (need to be R | |||||||||||||||||||
var_age |
Age variable. Several format are accepted
Missing age value must be precise in the option | |||||||||||||||||||
var_cases |
Number of event (cases, deaths, ...) variable. | |||||||||||||||||||
var_py |
Population year variable. | |||||||||||||||||||
var_year |
Time variable. | |||||||||||||||||||
type |
Type of the plot:
| |||||||||||||||||||
missing_age |
Age value representing the missing age cases. | |||||||||||||||||||
logscale |
Logical value: if | |||||||||||||||||||
db_rate |
The denominator population. Default is 100000. | |||||||||||||||||||
first_age |
First age group included, must be between 1 and 17. 1 represents 0-4, 2 represents 5-9, ... 5 represents 20-24 etc. | |||||||||||||||||||
last_age |
Last age group included, must be between 2 and 18. 2 represents 5-9, ... 5 represents 20-24, ... 18 represents 85+ etc. | |||||||||||||||||||
year_group |
Usually, data are regrouped in 5 years period. | |||||||||||||||||||
age_dropped |
Only if some age grouped are missing in the data.
Logical value: if | |||||||||||||||||||
plot_title |
Title of the plot. | |||||||||||||||||||
format_export |
export the graph in different format:
The filename is the | |||||||||||||||||||
graph_dev |
If the plot is embedded in a graphics Device function (such as pdf()), the graph_dev option should be set to TRUE for the first graph to avoid a blank page. |
Details
This function is design the plot a the age-specific cohort and period plot.
The type
option allow to choose between the 3 different graphics: "Cohort", "Period", or "Both".
Please note than the cohort plot and the period plot can be superimposed if the first_age
is too low.
Value
Return a plot.
Author(s)
Mathieu Laversanne
See Also
csu_group_cases
csu_merge_cases_pop
csu_asr
csu_cumrisk
csu_eapc
csu_ageSpecific
csu_ageSpecific_top
csu_bar_top
csu_time_trend
Examples
data(csu_registry_data_2)
# you can import your data from csv file using read.csv:
# mydata <- read.csv("mydata.csv", sep=",")
# to select only 1 population
test <- subset(csu_registry_data_2,registry == 84020 & sex == 1)
# plot cohort graph from 25-29 years until 75-79 years.
csu_trendCohortPeriod(df_data=test,
missing_age =99,
plot_title = "USA, Liver, males")
# plot Period graph from 0-5 until 85+.
csu_trendCohortPeriod(df_data=test,
missing_age =99,
plot_title = "USA, Liver, males",
type="Period",
first_age=1,
last_age=18)
# plot Cohort-Period graph from 30-34 years until 70-74 years.
csu_trendCohortPeriod(df_data=test,
missing_age =99,
plot_title = "USA, Liver, males",
type="Both",
first_age=7,
last_age=15)
# plot Cohort-Period graph from 30-34 years until 70-74 years with Y axis normal scale.
csu_trendCohortPeriod(df_data=test,
missing_age =99,
plot_title = "USA, Liver, males",
type="Both",
first_age=7,
last_age=15,
logscale=FALSE)
# plot Cohort graph from 25-29 years until 75-79 years, with data grouped in 2 years period.
csu_trendCohortPeriod(df_data=test,
missing_age =99,
plot_title = "USA, Liver, males",
type="Cohort",
year_group = 2)
# Plot embedded in a graphic device
pdf("example_test.pdf")
csu_trendCohortPeriod(df_data=test,
missing_age =99,
plot_title = "USA, Liver, males",
type="Both",
first_age=7,
last_age=15,
graph_dev=TRUE)
csu_trendCohortPeriod(df_data=test,
missing_age =99,
plot_title = "USA, Liver, males",
type="Both",
first_age=7,
last_age=15,
logscale=FALSE)
dev.off()