csu_time_trend: csu_time_trend

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

Description

csu_time_trend plot stats over year.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
csu_time_trend(df_data,
		var_trend = "asr",
		var_year = "year",
		group_by = NULL,
		logscale = FALSE,
		smoothing = NULL,
		legend = csu_trend_legend(),
		color_trend = NULL,
		ytitle = "Age standardized rate per 100,000",
		plot_title = "csu_title") 

Arguments

df_data

Data (need to be R data.frame format, see example to import csv file).

var_trend

Statistics variable to be plot on Y axis.
Usually for the ASR, but it could be the cumulative risk, or the number of cases.

var_year

Time variable.

group_by

Variable to compare different age specific rate (sex, country, cancer ...).
Only one variable can be chosen.

logscale

Logical value: if TRUE Y-axis use logscale.

smoothing

Apply a smoothing using the R loess function.
. The numerical parameter controls the degree of smoothing.
See option span in loess.

legend

legend option: see csu_trend_legend.
Use only if group_by is not NULL.

color_trend

Vector of color for the trend. The color codes are hexadecimal (e.g. "#FF0000") or predefined R color names (e.g. "red").

ytitle

Y-axis title. Default is "Age standardized rate per 100,000".

plot_title

Title of the plot.

Details

This function is design the plot a statistics over time. It has been design for the ASR by year, but can be used for other statistics over time period. The group_by option allow to compare different population or cancer.

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_trendCohortPeriod

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
	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_label == "Colombia, Cali")

	# to change sex variable to factor with label
	test$sex <- factor(test$sex, levels=c(1,2), labels=c("Male", "Female"))

	# to calculate the asr
	df_asr <- csu_asr(
		test,missing_age = 99,
		group_by  = c("registry", "registry_label", "year", "sex", "ethnic"),
		var_age_group =  c("registry", "registry_label")
		)


	# plot ASR ove year, by sex.
	csu_time_trend(df_asr, group_by="sex",
			  plot_title = "Colombia, Liver")

	# plot ASR over year, by sex, with small smoothing.
	csu_time_trend(df_asr, group_by="sex",
			  plot_title = "Colombia, Liver",
			  smoothing = 0.3)


	# plot ASR over year, by sex, with high smoothing.
	csu_time_trend(df_asr, group_by="sex",
			  plot_title = "Colombia, Liver",
			  smoothing = 0.5)

	# Plot embedded in a graphic device
	pdf("test.pdf",width = 11.692 , height =  8.267) 
	csu_time_trend(df_asr, group_by="sex",
			  plot_title = "Colombia, Liver",
			  smoothing = 0.3)

	csu_time_trend(df_asr, group_by="sex",
			  plot_title = "Colombia, Liver",
			  smoothing = 0.5)

	dev.off()
			

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