Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
R in Action, Second Edition.pdf
Скачиваний:
540
Добавлен:
26.03.2016
Размер:
20.33 Mб
Скачать

Summary

531

Note that unlike previous approaches, this approach to dynamic report generation involves two files—the Word template and an R script. The R code isn’t directly embedded in the Word document.

In this section, you’ve used the R2wd package, but others are available. The ReporteRs package (http://davidgohel.github.io/ReporteRs) is a serious contender for dynamically creating Microsoft Office documents from R. In general, technologies that connect R with Microsoft Office are developing rapidly, so you can expect new options in the future.

22.6 Summary

In this chapter, you’ve seen several ways that R results can be incorporated into reports. The reports are dynamic in the sense that changing the data and reprocessing the code results in an updated report. You learned methods for creating web pages, typeset documents, Open Document Format reports, and Microsoft Word documents.

There are several advantages to the template approach described in this chapter. By embedding the code needed to perform statistical analyses directly into the report template, you can see exactly how the results were calculated. Six months from now, you can easily see what was done. You can also modify the statistical analyses or add new data and immediately regenerate the report with minimum effort. Additionally, you avoid the need to cut and paste and reformat the results. This by itself is worth the price of admission.

The templates in this chapter are static in the sense that their structure is fixed. Although not covered here, you can also use these methods to create a variety of expert reporting systems. For example, the output of an R code chunk can depend on the data submitted. If numeric variables are submitted, a scatterplot matrix can be produced. Alternatively, if categorical variables are submitted, a mosaic plot can be produced. In a similar fashion, the explanatory text that is generated can depend on the results of the analyses. Using R’s if/then construct makes the possibilities for customization endless. You can use this approach to create a sophisticated expert system.

In this book, we’ve talked about getting your data into R, cleaning it up, analyzing it, graphing it, and presenting it to others. We’ve discussed a great many topics. The afterword considers where you may want to go next.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]