Один из вариантов - захватить выходные данные и направить их во временный файл
capture.output(plot(mice_plot,
col = c('navyblue','yellow'),
ylab = c("Proporção de Dados Faltantes","Padrão de dados Faltantes"),
numbers = T,
sortVars = T,
sortCombs = T,
gap = 2), file = tempfile())
- проверка в уценке
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r first}
suppressMessages(library(VIM))
ds <- structure(list(RC_1 = c(4, 5, 5, 7, 7, 6, 5, 5, 5, 5, 7, 5, 7,
7, 6, 5, 5, 5, 6, 5), RC_2 = c(NA, 7, 7, 6, 5, 3, 5, 5, 5, 3,
5, 6, 7, 6, 5, 4, 5, 5, 7, 5), RC_3 = c(7, 4, 4, 7, 5, 6, 7,
5, 5, 4, 5, 5, 7, 4, 5, 4, 5, 5, 6, 6), RC_4 = c(7, 7, 5, 7,
6, 5, 6, 5, 5, 5, 6, 5, 7, 7, 6, 5, 5, 5, 6, 6)), row.names = c(NA, -20L), class = c("tbl_df", "tbl", "data.frame"))
mice_plot <- aggr(ds, plot = F)
```
```{r second, echo=FALSE}
capture.output(plot(mice_plot,
col = c('navyblue','yellow'),
ylab = c("Proporção de Dados Faltantes","Padrão de dados Faltantes"),
numbers = T,
sortVars = T,
sortCombs = T,
gap = 2), file = tempfile())
```
- выход
Вывод из plot.aggr
cat
отпечатков
getAnywhere('plot.aggr')
...
...
if (sortVars) {
if (!imputed)
cat("\n Variables sorted by number of missings: \n")
else if (!miss_imp)
cat("\n Variables sorted by number of imputed missings: \n")
else cat("\n Variables sorted by number of missings or imputed missings: \n")
tmp <- data.frame(Variable = cn, Count = miss)
print(tmp, row.names = FALSE)
}
invisible()
}