我想在单个页面上监控 R 中生成的数字的基本质量,例如每页的字节大小,......我现在只能对平均页面进行质量保证,请参阅下面的章节。我认为该任务必须有一些内置的东西而不是平均措施。
产生4页的代码,Rplots.pdf
我想知道输出中每页的字节大小;也欢迎页面输出的任何其他统计信息;你可以在这里通过对象获得基本的内存监控,但我希望它对应于 PDF 中的输出
# https://stat.ethz.ch/R-manual/R-devel/library/graphics/html/plot.html
require(stats) # for lowess, rpois, rnorm
plot(cars)
lines(lowess(cars))
plot(sin, -pi, 2*pi) # see ?plot.function
## Discrete Distribution Plot:
plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10,
main = "rpois(100, lambda = 5)")
## Simple quantiles/ECDF, see ecdf() {library(stats)} for a better one:
plot(x <- sort(rnorm(47)), type = "s", main = "plot(x, type = \"s\")")
points(x, cex = .5, col = "dark red")
## TODO summarise here the byte size of figures in the figures (1-4)
# Output: Rplot.pdf where 4 pages; I want to know the size of each page in bytes
我目前正在命令行中进行基本的质量保证,但想将其中的一些移到 R 中,以更快地观察错误。
预期输出:字节大小,例如第 4 列ls -l
获取输出文档中平均单个页面的字节大小
限制
- 要求页面中数据的同质性。此方法仅适用于所有页面均来自同一样本的情况。否则很麻烦,因为它只是平均的,没有描述个别现象。其他可能的弱点
- PDF 元素和元数据。整体考虑 pdf 文件,而不是关注图形对象本身。所以这限制了绝对值的使用,因为文件大小还包含标题和其他与图形对象无关的元数据。
代码
filename <- "main.pdf"
filesize <- file.size(filename)
# http://unix.stackexchange.com/q/331175/16920
pages <- Rpoppler::PDF_info(filename)$Pages
# print page size (= filesize / pages)
pagesize <- filesize / pages
## data of example file
num 7350960
int 62
num 118564
输入:任何 62 页文档
输出:平均单个页面大小 (118564)
测试和答案
输出,但您不能轻松地将输入更改为您想要的 pdf 文件
files size_bytes
[1,] "./test_page_size_pdf/page01.pdf" "4,123,942"
[2,] "./test_page_size_pdf/page02.pdf" " 4,971"
[3,] "./test_page_size_pdf/page03.pdf" " 4,672"
[4,] "./test_page_size_pdf/page04.pdf" " 5,370"
输入:任何 64 页文档
预期输出:67 (= 64 + 3) 页,而不是 4 页已分析
R:3.3.2
操作系统:Debian 8.5