csu_time_trend
plot stats over year.
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")
Data (need to be R data.frame
format, see example to import csv file).
Statistics variable to be plot on Y axis. Usually for the ASR, but it could be the cumulative risk, or the number of cases.
Time variable.
Variable to compare different age specific rate (sex, country, cancer ...). Only one variable can be chosen.
Logical value: if TRUE
Y-axis use logscale.
Apply a smoothing using the R loess function. .
The numerical parameter controls the degree of smoothing.
See option span
in loess
.
legend option: see csu_trend_legend
.
Use only if group_by
is not NULL
.
Vector of color for the trend. The color code are hexadecimal (see example).
Y-axis title. Default is "Age standardized rate per 100,000".
Title of the plot.
Return a plot.
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.
csu_group_cases
csu_merge_cases_pop
csu_asr
csu_eapc
csu_ageSpecific
csu_ageSpecific_top
csu_bar_top
csu_trendCohortPeriod
# NOT RUN {
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 <- csu_registry_data_2[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"),
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)
# }
# NOT RUN {
# 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()
# }
Run the code above in your browser using DataLab