你内联的不是有效的R代码。试试这样的:
```{r, echo=FALSE}
x <- rnorm(50)
ks <- ks.test(x, "pnorm", mean=mean(x), sd=sd(x))
df <- length(x)
```
Based on K-S test (D(`r df`) = `r ks$statistic[[1]]`, p = `r ks$p.value[[1]]`), we can conlude something.
但你可能想格式化这些数字以便打印,所以你可以尝试更像这样的方法:
Based on K-S test (D(`r df`) = `r format(round(ks$statistic[[1]], 2), nsmall = 2)`, p = `r format(round(ks$p.value[[1]], 2), nsmall = 2)`), we can conlude something.