Why is this graph showing up twice in R Markdown? -
```{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 year , month", ylab="flood count", xlab="year" ) ```
when knit, histogram show twice. missing here?
@hrbrmstr correct, cannot reproduce problem. because of that, cannot advance suspect: plotting histogram every factor of second argument of function.
consider simple dataset:
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 )
lattice functions rely on formula. in example above plot variable trans
every level of factor variable gender
. how can suppose, gender
has 2 levels, male , female, hence have 2 plots.
otherwise, if remove operator |
, have single histogram variable trans
.
histogram(~trans, data = dt )
Comments
Post a Comment