0

我的目标是将数据帧、aov 输出等保存为已由 R 包处理的图像,该 R 包将 r 数据格式化为科学期刊就绪格式,例如sjPlot.

>library(sjPlot)
>library(webshot)
>library(tableHTML)

>tab_df(df, alternate.rows = T, title = "Table 1 - Site-Event", col.header = c("Event", "Site", "Volume\n(mm)", "Total\nRainfall\n(mm)", "Runoff\nRatio\n(%)", "24 hour\nRainfall\n(mm)", "7 day\nRainfall\n(mm)", "Max\nrainfall\nIntensity\n(mm/hr)", "Response\nTime\n(hours)", "Max Flow\nRate\n(mm/hr)","TP Load\n(g/ha)", "SRP Load\n(g/ha)", "PP Load\n(g/ha)"), file = "/home/ryrugg80/working/Table_1.html")

webshot当我尝试转换以下的 html 输出时,我最初遇到了这个错误sjPlot

> webshot("/home/ryrugg80/working/Table_1.html", "/home/ryrugg80/working/Table_1.png")
Auto configuration failed
135096819605120:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libssl_conf.so): libssl_conf.so: cannot open shared object file: No such file or directory
135096819605120:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
135096819605120:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=ssl_conf, path=ssl_conf
135096819605120:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=ssl_conf
Error in webshot("/home/ryrugg80/working/Table_1.html", "/home/ryrugg80/working/Table_1.png") : 
  webshot.js returned failure value: 1

因此,我寻找了webshot将 html 格式导出为 jpeg 的功能的替代方法,例如使用tableHTML包:

>df %>%
  head() %>%
  tableHTML() %>%
  add_theme('scientific') %>%
  tableHTML_to_image()

但是,webshot.js即使我只是调用该tableHTML函数,也会返回部分错误:

Error in webshot::webshot(temp_file, file = image, selector = selector,  : 
  webshot.js returned failure value: 1

所以我猜测 R 中输出的任何 html --> 图像文件webshot取决于我的 macbook air 没有任何问题webshot

我想知道是否

  1. webshot在 chromebook linux beta 上运行的 R 中使用存在任何已知问题
  2. 如果不是我的操作系统和机器,那是webshot.js什么?(我install.phantomjs()成功运行,没有出现任何错误,所以我相信我拥有webshot包工作所需的一切)。
  3. 我在将 html 格式导出到 R 中的图像的包中是否正确?所有这些包都webshot以某种方式使用/依赖?
  4. 有人可以在 R 中推荐一个可能不需要 html 快照的工作流,只需将 R 中的表格以科学期刊就绪格式直接导出为 .png、.jpeg 等文件。

这是我的数据框:

df<-structure(list(Event = c("03262020", "03292020", "04132020", 
"04272020", "05122020", "05122020", "08052020", "08052020", "09302020", 
"09302020", "12012020", "12012020", "12252020", "12252020", "01172021", 
"01172021", "03112021", "03112021", "04162021", "04162021", "04222021", 
"04222021", "04302021", "04302021", "05062021", "05062021", "07022021", 
"07022021", "07092021", "07092021", "07132021", "07132021", "07142021", 
"07142021", "07182021", "07182021", "07192021", "07192021", "07212021", 
"07212021"), Site = c("AHSSUB", "AHSSUB", "AHSSUB", "AHSSUB", 
"DCSSUB", "DCNSUB", "DCSSUB", "DCNSUB", "DCSSUB", "DCNSUB", "DCNSUB", 
"AHSSUB", "DCNSUB", "AHSSUB", "DCNSUB", "AHSSUB", "DCSSUB", "DCNSUB", 
"DCSSUB", "DCNSUB", "DCSSUB", "DCNSUB", "DCSSUB", "DCNSUB", "DCSSUB", 
"DCNSUB", "DCSSUB", "DCNSUB", "DCSSUB", "DCNSUB", "DCSSUB", "DCNSUB", 
"DCSSUB", "DCNSUB", "DCSSUB", "DCNSUB", "DCSSUB", "DCNSUB", "DCSSUB", 
"DCNSUB"), `Volume (mm)` = c(2.04067796610169, 10.4516514837405, 
12.0899894067797, 3.09391949152542, 1.41294374923706, 4.21271443223462, 
1.59375, 3.55901443324138, 0.302790000057221, 1.07257113427231, 
12.6589515443782, 9.74302966101695, 29.9882288679929, 23.9495879264875, 
4.36980618758054, 1.65544279626534, 40.0362483642578, 56.4818628785438, 
14.6674424987793, 21.8118525793331, 7.74199875183105, 13.8286886577803, 
22.0856943725586, 35.3692329856637, 13.9519987487793, 23.3986391752577, 
25.85791875, 28.4748432969555, 8.94806812438965, 9.56362886597938, 
2.43910875015259, 3.1785927822467, 1.071159375, 1.58357010296694, 
18.6393225036621, 22.7730494925902, 5.33072062683105, 5.99860515413579, 
8.219625, 11.0847494815158), `Total Rainfall (mm)` = c(0, 18.288, 
17.78, 24.638, 16.764, 16.764, 65.024, 65.024, 53.086, 53.34, 
29.718, 29.718, 28.194, 28.194, 20.574, 20.574, 1.016, 1.016, 
46.228, 45.466, 17.018, 17.018, 29.972, 37.338, 25.146, 25.146, 
70.358, 70.358, 28.194, 28.194, 18.796, 18.796, 7.366, 7.366, 
51.816, 51.816, 27.686, 26.924, 20.066, 20.066), `Runoff Ratio (%)` = c(NA, 
0.571503252610483, 0.679976907017979, 0.125575107213468, 0.0842844040346612, 
0.251295301374052, 0.0245101808562992, 0.0547338587789337, 0.00570376370525601, 
0.0201081952432004, 0.425969161598298, 0.327849440104211, 1.06363867730698, 
0.84945690311724, 0.212394584795399, 0.0804628558503615, NA, 
NA, 0.317284816534985, 0.479739862300029, 0.454930000695208, 
0.812591882581989, 0.736877564812445, 0.947271760288812, 0.554839686183858, 
0.93051138054791, 0.367519240882345, 0.40471365440967, 0.317374906873436, 
0.339207947293019, 0.129767437228803, 0.169110065026958, 0.145419410127613, 
0.214983722911612, 0.359721369917827, 0.439498407684696, 0.192542101669835, 
0.22279769551834, 0.409629472739958, 0.552414506205312), `24 hour Rainfall (mm)` = c(0, 
6.096, 6.096, 14.986, 9.906, 6.096, 33.528, 33.528, 41.91, 25.654, 
8.382, 9.652, 1.778, 1.778, 0.508, 0.508, 0, 0, 17.018, 12.446, 
5.588, 0.254, 3.81, 2.032, 0.508, 2.794, 10.16, 15.748, 8.636, 
11.684, 10.414, 0.254, 6.858, 0.254, 7.874, 13.97, 20.574, 23.622, 
7.112, 7.112), `7 day Rainfall (mm)` = c(9.398, 14.986, 17.526, 
15.24, 11.938, 8.128, 38.862, 38.862, 45.212, 28.956, 8.382, 
9.652, 1.778, 1.778, 4.064, 4.064, 0, 0, 17.018, 12.446, 52.07, 
46.736, 11.176, 9.906, 37.084, 38.862, 17.526, 23.114, 82.55, 
85.598, 39.878, 31.242, 53.848, 47.244, 34.036, 40.132, 74.168, 
77.978, 69.596, 69.596), `Max rainfall Intensity (mm/hr)` = c(-Inf, 
2.286, 4.064, 4.318, 3.81, 3.81, 17.018, 17.018, 9.144, 9.144, 
5.588, 5.588, 6.35, 6.35, 4.572, 4.572, 1.016, 1.016, 5.334, 
5.334, 2.286, 2.286, 3.302, 3.302, 4.064, 4.064, 8.382, 8.382, 
5.588, 5.588, 10.16, 10.16, 6.604, 6.604, 8.128, 8.128, 8.128, 
8.128, 10.16, 10.16), `Response Time (hours)` = c(NA, 4.16666666666667, 
4.08333333333333, 4.66666666666667, 3.58333333333333, 2.5, 12.75, 
12.25, 10.1666666666667, 8.25, 2.16666666666667, 3.16666666666667, 
2.75, 2.75, 22.6666666666667, 21.6666666666667, -5, -35, 10.4166666666667, 
8.33333333333333, 3.91666666666667, 1, 23.4166666666667, 11.5833333333333, 
1, 1.91666666666667, 5, 5.25, 7.66666666666667, 8.08333333333333, 
1.58333333333333, 1, 12.4166666666667, 11.9166666666667, 9.5, 
11.1666666666667, 1, 23.1666666666667, 35, 25), `Max Flow Rate (mm/hr)` = c(0.22271186440678, 
0.270508474576271, 1.9871186440678, 0.260847457627119, 0.244395, 
0.583868041237113, 0.716355, 2.07248659793814, 0.110475, 0.33060618556701, 
1.94288659793814, 1.38605084745763, 2.23623092783505, 1.81138983050847, 
0.29579381443299, 0.0729915254237288, 1.37988, 2.22695257731959, 
1.003365, 1.11080412371134, 0.33057, 0.398746391752577, 1.397655, 
2.18969072164949, 1.349235, 2.03314639175258, 1.3248, 2.06959175257732, 
1.313955, 2.05771546391753, 0.63486, 0.730911340206186, 0.31131, 
0.272931958762887, 1.526895, 2.4552, 0.924795, 0.972742268041237, 
1.452465, 2.43411958762887), `TP Load (g/ha)` = c(4.25692988443846, 
27.8006728254469, 70.1810360628333, 11.9330750010108, 12.3265555053949, 
36.8174982439611, 4.44504926726222, 10.6117348449746, 4.54794424585998, 
17.8328055389149, 68.7433761665502, 81.0744443182218, 147.413539738999, 
119.209792048244, 9.57343016703104, 1.78588126696604, 181.149163246155, 
226.223584204605, 73.9970071017742, 98.6889262543511, 24.1213355660439, 
34.6017517256983, 139.449646413326, 189.558829376378, 112.37001991272, 
171.812800377915, 53.264238089323, 58.1612158559032, 26.5617941766977, 
31.3029888241561, 7.50507989898324, 10.0566259057251, 2.69859536364675, 
1.48605661447515, 91.1078358888626, 141.374159694947, 41.6934734433889, 
30.6892230461553, 58.6717744767666, 73.526094131863), `SRP Load (g/ha)` = c(1.34711869292508, 
8.73684677700538, 20.2819923728199, 3.52364645502662, 8.1493668705225, 
23.4814269272323, 0.819089024793357, 3.12102175864977, 1.52886190172285, 
5.74630562792119, 24.406349499201, 46.4589389030543, 53.1728966948912, 
85.2571822829166, 2.71595972868585, 1.07385517850434, 66.5963070392609, 
85.4840843947892, 11.8901212364435, 19.4098025560379, 5.37658046372235, 
7.54559843196082, 27.4970724731684, 43.3958766140889, 27.3447283059359, 
47.3142137232515, 21.4630649760365, 22.9026997949659, 10.8961454853415, 
12.4315990922377, 2.17145763803273, 4.05620242056158, 0.883019731380045, 
0.586948093487737, 26.7891993820667, 50.5455818618696, 2.66450296901166, 
2.99758492210477, 18.7665024772286, 23.737132610734), `PP Load (g/ha)` = c(2.90981119046103, 
19.0638260484415, 49.8990437236883, 8.4094285417748, 4.17718863114715, 
13.3360713044393, 3.62596024386585, 7.49071309246968, 3.01908234320581, 
12.0864999109937, 44.3370266796387, 34.6155053814926, 94.2406430686872, 
33.9526097484901, 6.85747043680899, 0.712026088987872, 114.552856206894, 
140.739499760657, 62.1068858504295, 79.2791236798788, 18.7447551041842, 
27.0561532998822, 111.952573895454, 146.162952688551, 85.025291621685, 
124.498586703822, 31.8011731207371, 35.2585160609373, 15.6656486913562, 
18.8713897380632, 5.33362226001918, 6.00042348362736, 1.8155756322667, 
0.899108520411339, 64.3186365067959, 90.8285778084981, 39.028970465064, 
27.6916381255868, 39.9052719920874, 49.7889615088394)), row.names = c(NA, 
-40L), class = "data.frame")
4

0 回答 0