csu_trendCohortPeriod: csu_trendCohortPeriod

Description Usage Arguments Details Value Author(s) See Also Examples

Description

csu_trendCohortPeriod plot cohort period age specific graph.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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 data.frame format, see example to import csv file).

var_age

Age variable. Several format are accepted

1 "0-4" 0
2 "5-9" 5
3 "10-14" 10
... ... ...
17 "80-84" 80
18 "85+" 85

Missing age value must be precise in the option missing_age.
Last age group will always be considere without size (ie: 80+,85+, etc..).

var_cases

Number of event (cases, deaths, ...) variable.

var_py

Population year variable.

var_year

Time variable.

type

Type of the plot:

"Cohort" Cohort graph.
"Period" Period graph.
"Both" Cohort Period graph.
missing_age

Age value representing the missing age cases.

logscale

Logical value: if TRUE Y-axis use logscale.

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.
Default is 6 (25-29 years).

last_age

Last age group included, must be between 2 and 18. 2 represents 5-9, ... 5 represents 20-24, ... 18 represents 85+ etc.
Default is 16 (75-79 years).
To plot the age group from 15-19 years until 65-69 years, use: first_age(4), last_age(14)

year_group

Usually, data are regrouped in 5 years period.
. The numerical parameter controls the size of the group.

age_dropped

Only if some age grouped are missing in the data. Logical value: if TRUE, assume the age group not used are already dropped from the data.
First_age and last_age option must still be filled.

plot_title

Title of the plot.

format_export

export the graph in different format:

NULL Plot in R studio windows.
"pdf" Export in PDF format.
"tiff" Export in TIFF 300dpi format.
"png" Export in PNG 200dpi format.
"svg" Export in SVG format. Can be edit with https://inkscape.org/fr/.

The filename is the plot_title option.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
	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()
		

Rcan documentation built on July 1, 2020, 10:20 p.m.