This is due to a bug in the evaluate
package. I have fixed it and sent the patch to the package author. For now, you can
library(devtools)
install_github('evaluate', 'yihui')
install_github('knitr', 'yihui')
문제
Below is a minimal example:
\documentclass{article}
\begin{document}
<<data, results='hide', echo=FALSE, include=FALSE>>=
library(rms)
fake.survival.data <- Surv(1:30, rep(1, 30))
fit <- survfit(fake.survival.data ~ 1)
@
<<threeplots>>=
survplot(fit, xlab = "zeroth plot")
for(j in c("first plot", "second plot")){
survplot(fit, xlab = j)
}
@
Of the two plots in the for-loop only the second is produced (in general: only the last). The problem seems to be with survplot specifically: if we add an ordinary plot after one of the survplots such as in:
\documentclass{article}
\begin{document}
<<data, results='hide', echo=FALSE, include=FALSE>>=
library(rms)
fake.survival.data <- Surv(1:30, rep(1, 30))
fit <- survfit(fake.survival.data ~ 1)
@
<<threeplots>>=
survplot(fit, xlab = "zeroth plot")
plot(c(1,1), xlab = "normal plot")
for(j in c("first plot", "second plot")){
survplot(fit, xlab = j)
}
@
or:
\documentclass{article}
\begin{document}
<<data, results='hide', echo=FALSE, include=FALSE>>=
library(rms)
fake.survival.data <- Surv(1:30, rep(1, 30))
fit <- survfit(fake.survival.data ~ 1)
@
<<threeplots>>=
survplot(fit, xlab = "zeroth plot")
for(j in c("first plot", "second plot")){
survplot(fit, xlab = j)
plot(c(1, 1) xlab = j)
}
@
all plots are produced where you expect them.
Does anyone know what happens here?
Thanks in advance, Vincent
해결책
This is due to a bug in the evaluate
package. I have fixed it and sent the patch to the package author. For now, you can
library(devtools)
install_github('evaluate', 'yihui')
install_github('knitr', 'yihui')