csu_time_trend {Rcan} | R Documentation |
csu_time_trend
Description
csu_time_trend
plot stats over year.
Usage
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 |
var_trend |
Statistics variable to be plot on Y axis. |
var_year |
Time variable. |
group_by |
Variable to compare different age specific rate (sex, country, cancer ...). |
logscale |
Logical value: if |
smoothing |
Apply a smoothing using the R loess function. |
legend |
legend option: see |
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
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()