r 对象未打印在文本中
r object not printed in the text
一些 R 对象在 Rmarkdown 中打印没有问题,但没有使用 papaja 模板打印。它不会生成任何错误消息。例如,假设我写了一个降价文件如下:
```{r setup, include = FALSE}
knitr::opts_chunk$set(include = FALSE)
```
```{r}
library("pacman")
p_load(plyr, dplyr, ggplot2, lmSupport, lme4, psycho, psych,
GPArotation, tidyverse, tinytex, afex, foreign,purrr, lavaan, citr,
papaja)
options(scipen = 0, digits = 3)
DF <- data.frame(id = paste0("ID.", 1:200),
x = sample(c("control", "treat"), 200, replace = TRUE),
y = rnorm(200))
m <- lm(y ~x, data= DF)
summary(m)
s1<-apa_print.lm(m)
s1$statistic[2]
```
# Result
I fitted a linear regression model in which condition (control vs.
treat) predicts scores. Treat group showed significantly higher scores
compared to control group, `r s1$estimate[2]`, `r s1$statistic[2]`.
好问题。这不是 papaja
中的预期行为,将很快在开发版本中修复。问题在于内联挂钩无法正确处理列表。如果你 select 列表元素使得输出对象是一个向量,它也应该在当前版本中工作。
您可以使用您发现的 s1$estimate[2][1]
或 s1$estimate[[2]]
,但就个人而言,我更喜欢通过 s1$estimate[["xtreat"]]
或 s1$estimate$xtreat
按名称建立索引。
顺便说一句,如果你想报告估计和测试统计数据,你可以使用 full_result
元素。
所以对于你的例子,我建议:
```{r setup, include = FALSE}
library("papaja")
```
```{r}
DF <- data.frame(id = paste0("ID.", 1:200),
x = sample(c("control", "treat"), 200, replace = TRUE),
y = rnorm(200))
m <- lm(y ~ x, data = DF)
s1 <- apa_print.lm(m)
```
# Result
I fitted a linear regression model in which condition (control vs.
treat) predicts scores. Treat group showed significantly higher scores
compared to control group, `r s1$full_result$xtreat`.
一些 R 对象在 Rmarkdown 中打印没有问题,但没有使用 papaja 模板打印。它不会生成任何错误消息。例如,假设我写了一个降价文件如下:
```{r setup, include = FALSE}
knitr::opts_chunk$set(include = FALSE)
```
```{r}
library("pacman")
p_load(plyr, dplyr, ggplot2, lmSupport, lme4, psycho, psych,
GPArotation, tidyverse, tinytex, afex, foreign,purrr, lavaan, citr,
papaja)
options(scipen = 0, digits = 3)
DF <- data.frame(id = paste0("ID.", 1:200),
x = sample(c("control", "treat"), 200, replace = TRUE),
y = rnorm(200))
m <- lm(y ~x, data= DF)
summary(m)
s1<-apa_print.lm(m)
s1$statistic[2]
```
# Result
I fitted a linear regression model in which condition (control vs.
treat) predicts scores. Treat group showed significantly higher scores
compared to control group, `r s1$estimate[2]`, `r s1$statistic[2]`.
好问题。这不是 papaja
中的预期行为,将很快在开发版本中修复。问题在于内联挂钩无法正确处理列表。如果你 select 列表元素使得输出对象是一个向量,它也应该在当前版本中工作。
您可以使用您发现的 s1$estimate[2][1]
或 s1$estimate[[2]]
,但就个人而言,我更喜欢通过 s1$estimate[["xtreat"]]
或 s1$estimate$xtreat
按名称建立索引。
顺便说一句,如果你想报告估计和测试统计数据,你可以使用 full_result
元素。
所以对于你的例子,我建议:
```{r setup, include = FALSE}
library("papaja")
```
```{r}
DF <- data.frame(id = paste0("ID.", 1:200),
x = sample(c("control", "treat"), 200, replace = TRUE),
y = rnorm(200))
m <- lm(y ~ x, data = DF)
s1 <- apa_print.lm(m)
```
# Result
I fitted a linear regression model in which condition (control vs.
treat) predicts scores. Treat group showed significantly higher scores
compared to control group, `r s1$full_result$xtreat`.