1

I have get lots of result from my model and I need to copy the results to MS word. But it's too much!! I'm going to copy over 30,000 results! my result just like down here. I want to every disease in every sheet. I can do this with code like this:

enter image description here

list <- split(df,df$disease)
ImportExport::excel_export(list,'result.xlsx')

That's not enough. The best format of the results I wanted should like the picture. For better observation, when P is less than 0.05, the value is bold.

Can R do this job?

Any help will be highly appreaciate!

disease people  pollutant   lag value   p
I21 total   PM2.5   0   0.07(-0.4,0.55) 0.01
I21 total   PM2.5   1   0.35(0.1,0.61)  0.3
I21 total   PM2.5   2   0.33(0.11,0.54) 0.04
I21 total   PM10    0   0.07(-0.4,0.55) 0.01
I21 total   PM10    1   0.35(0.1,0.61)  0.3
I21 total   PM10    2   0.33(0.11,0.54) 0.04
I21 man PM2.5   0   -0.02(-0.45,0.41)   0.01
I21 man PM2.5   1   0.39(-0.02,0.8) 0.3
I21 man PM2.5   2   0.2(-0.14,0.54) 0.04
I21 man PM10    0   0.12(-0.39,0.63)    0.01
I21 man PM10    1   -0.1(-0.74,0.55)    0.3
I21 man PM10    2   0.19(-0.57,0.95)    0.04
I21 woman   PM2.5   0   -1(-2.7,0.74)   0.01
I21 woman   PM2.5   1   -0.05(-1.52,1.45)   0.3
I21 woman   PM2.5   2   -0.3(-1.63,1.04)    0.04
I21 woman   PM10    0   -0.17(-1.45,1.13)   0.01
I21 woman   PM10    1   -0.9(-2.17,0.38)    0.3
I21 woman   PM10    2   -1.64(-2.92,-0.35)  0.04
I24 total   PM2.5   0   -0.8(-2.77,1.21)    0.01
I24 total   PM2.5   1   -0.2(-2.56,2.2) 0.3
I24 total   PM2.5   2   -1.31(-4.07,1.52)   0.04
I24 total   PM10    0   -0.76(-1.95,0.43)   0.01
I24 total   PM10    1   0.5(-0.34,1.34) 0.3
I24 total   PM10    2   0.32(-0.35,1)   0.04
I24 man PM2.5   0   -0.09(-0.74,0.58)   0.01
I24 man PM2.5   1   -0.49(-1.14,0.17)   0.3
I24 man PM2.5   2   -0.45(-1.08,0.19)   0.04
I24 man PM10    0   0.22(-1.13,1.59)    0.01
I24 man PM10    1   0.27(-0.99,1.56)    0.3
I24 man PM10    2   -0.47(-1.83,0.91)   0.04
I24 woman   PM2.5   0   -1.47(-4.9,2.09)    0.01
I24 woman   PM2.5   1   1.51(-0.47,3.53)    0.3
I24 woman   PM2.5   2   1.61(-0.14,3.4) 0.04
IceCreamToucan
  • 28,083
  • 2
  • 22
  • 38
ZW.Lee
  • 33
  • 2
  • Take a close look at `kableExtra` package on [__GitHub__](https://github.com/haozhu233/kableExtra) and [__especially Tutorial__](http://haozhu233.github.io/kableExtra/awesome_table_in_html.html). It is just brilliant for problems like this yours. I used to build HTML slides with heavy use of `kableExtra`. – Pavel Filatov Jun 07 '19 at 20:18
  • I would highly recommand `flextable` and `officer` for this. Works really well and you can customize any way you like, based on conditions. – Sven Jun 07 '19 at 20:22

0 Answers0