【发布时间】:2021-01-11 15:12:16
【问题描述】:
我的数据框包含从 2019 年 1 月到 2020 年 10 月在英格兰 9 个不同地区报告的 5 种犯罪类型(加上它们各自的发生次数)的列表。
我想为每个区域分别绘制以犯罪发生率为 Y 轴,以日期为 X 轴的图表,而不是多面图表。
为此,我必须挑选出我想要绘制的区域;我试过了
df$region == "Region_name"
但它没有成功。 任何建议将不胜感激!
这是我正在使用的数据框示例:
structure(list(
Region = c("Yorkshire and The Humber", "East of England",
"East Midlands", "North East", "South East", "South East", "South East",
"East Midlands", "East Midlands", "London", "North West", "South West",
"East of England", "East Midlands", "East Midlands", "South East",
"Yorkshire and The Humber", "East of England", "East of England",
"East of England"),
Date = structure(c(18109, 18383, 17928, 18293,
18414, 18536, 18170, 17987, 18322, 18140, 18383, 18475, 18231,
18048, 18353, 18322, 18475, 18170, 18109, 17897), class = "Date"),
Crime = c("Violence and sexual offences", "Robbery", "Violence and sexual offences",
"Robbery", "Burglary", "Violence and sexual offences", "Robbery",
"Burglary", "Violence and sexual offences", "Robbery", "Robbery",
"Burglary", "Robbery", "Theft", "Violence and sexual offences",
"Burglary", "Burglary", "Robbery", "Anti-social behaviour",
"Theft"),
Crime_occurrencies = c(21001L, 177L, 6033L, 82L,
2635L, 24096L, 590L, 1536L, 7388L, 3205L, 163L, 981L, 232L,
5339L, 6367L, 3375L, 3238L, 257L, 10982L, 7906L)),
class = "data.frame", row.names = c(NA, -20L))
【问题讨论】: