我正在查看dist3.Rmd
此处的示例模板:http ://www.R-exams.org/templates/dist3/ 。解决方案降价是提交后提供的一般反馈。我想创建反馈。
Solution
========
The distance $d$ of $p$ and $q$ is given by
$d^2 = (p_1 - q_1)^2 + (p_2 - q_2)^2$ (Pythagorean formula).
Hence $d = \sqrt{(p_1 - q_1)^2 + (p_2 - q_2)^2} =
\sqrt{(`r p[1]` - `r q[1]`)^2 + (`r p[2]` - `r q[2]`)^2}
= `r round(sol, digits = 3)`$.
\
```{r distplot, echo = FALSE, results = "hide", fig.path = "", fig.cap = ""}
par(mar = c(4, 4, 1, 1))
plot(0, type = "n", xlim = c(0, 6), ylim = c(0, 6), xlab = "x", ylab = "y")
grid(col = "slategray")
points(rbind(p, q), pch = 19)
text(rbind(p, q), c("p", "q"), pos = c(2, 4))
lines(rbind(p, q))
lines(c(p[1], p[1], q[1]), c(p[2], q[2], q[2]), lty = 2)
```
如果答案选择正确,我希望弹出一般反馈,如果答案错误,我希望显示毕达哥拉斯公式和图像提示,但不显示计算。我怎样才能做到这一点?