```{r scatterplot, fig.width=14, fig.height=14, echo=FALSE, results="hide"}
histogram(
~factor(
format(df_ian$newDate,"%b"),
levels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
) | factor(
format(newDate,"'%y")
),
data=df_ian, layout=(c(3,6)),
main="Flood Counts by year and month",
ylab="Flood Count",
xlab="Year"
)
```
当我编织时,直方图显示两次。我在这里缺少什么?
答案 0 :(得分:0)
考虑一个简单的数据集:
dt <- data.frame(gender = rep(c("Male", "Female"), c(4, 2) ), trans = rep(c("Car", "Bus",
"Bike"), c(3, 2, 1) ))
library(lattice)
histogram(~trans | gender, data = dt )
格子函数依赖于公式。在上面的示例中,您通过因子变量trans
的每个级别绘制变量gender
。你怎么想,gender
有两个级别,男性和女性,因此我们将有两个图。
否则,如果删除运算符|
,您将拥有变量trans
的单个直方图。
histogram(~trans, data = dt )