Search code examples
rpdfr-markdownsymbolsflextable

cannot print arrows symbol in pdf produced with RMarkdown


I am gettiing this results after creating a table in pdf with flextable

enter image description here

I do not know how to fix it and how to modify properly the yalm, if the problem depends on this, because I left everything as it is as default.

Here I am posting just one of dataframe I would like to print as flextable and include this horizontal arrows

dput(head(model_random[[1]][[1]], 60))
structure(list(something = c("A→B", "A→B", "A→B", "A→B", 
"A→B", "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", 
"A→B", "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", 
"A→B", "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", 
"A→B", "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", 
"A→B", "A→B"), A = c(50.0368835409195, 49.9992842206918, 
50.1838394874486, 50.1176549507243, 50.1010529015179, 49.821713095517, 
50.0698654258166, 49.9023807785062, 50.1478052632896, 49.8474946541399, 
50.125583771611, 50.0245256592517, 49.9639619226328, 49.9672433460124, 
49.9281524409641, 49.9795056995374, 49.7792220695405, 49.9358849340944, 
50.1172137552123, 49.7111044156362, 50.2921556948872, 50.0169633926026, 
50.0273607894839, 50.1207597292804, 49.9860929016013, 50.0713408270736, 
49.6186835491455, 49.9844826925892, 50.2323684845959, 49.9898805063105, 
50.0992891050281, 49.5389082649178, 50.1812597290405, 49.7834578109085
), B = c(50.1776428964591, 50.1813031157202, 50.1927613652949, 
50.1679213933357, 50.1569243982301, 50.1233335529302, 50.1749893807647, 
50.1549162541763, 50.1635921809174, 50.146455542177, 50.1054992604603, 
50.1039886051106, 50.0762789780625, 50.0330009165502, 50.0410459608984, 
50.0267687312948, 50.2259333568155, 50.0656668738789, 50.2259846449786, 
50.3278126226738, 50.1020984124345, 50.0134973819586, 50.040087658563, 
50.0505477459729, 50.1863603001512, 50.2375471508255, 50.2412852792546, 
50.1805273383299, 50.1344685033523, 50.1002066667137, 50.0923566514067, 
50.2417689993628, 50.2035852184223, 50.2314878531161), C = c(109, 
111, 109, 110, 112, 115, 111, 111, 111, 113, 114, 114, 114, 115, 
115, 115, 104, 114, 109, 77, 115, 115, 115, 115, 100, 104, 101, 
104, 115, 113, 115, 105, 99, 102), D = c(0.207627446155601, -0.00394797025625418, 
0.953715425118201, 0.700654921848441, 0.643959146300284, -1.44556692195395, 
0.399255232010291, -0.630141891907051, 0.903498336294232, -1.04130812390698, 
1.19037584778399, 0.235849487793271, -0.472450972502978, -0.992598309740363, 
-1.75041727525403, -0.765605969026731, -0.977181650250334, -0.97636848106905, 
0.518680175033174, -0.881282673032435, 2.86151065350567, 1.25679132846729, 
0.682524010248754, 2.38902303072274, -0.074624790727555, 0.300322806759241, 
-1.58035522114156, -0.0859554433937029, 1.72805139347118, -0.100986231967636, 
1.07506176886905, -1.9071582225074, 0.890338357790617, -0.935436508553472
), E = c(0.836234883045752, 0.996862866711249, 0.344118897285272, 
0.486226704786596, 0.52197709148008, 0.153103083617026, 0.691099560247056, 
0.530955270501434, 0.369815705614773, 0.301712272900562, 0.238295447393385, 
0.814302587703858, 0.638212051791818, 0.324586542757989, 0.0847649462526957, 
0.446681990016779, 0.332836775303587, 0.332558097391966, 0.6059238027773, 
0.385942947438544, 0.00566597171300206, 0.213326881710713, 0.497332936024347, 
0.0198050427456018, 0.94081101668899, 0.765084106174977, 0.120208357693328, 
0.931819756960404, 0.088727413048962, 0.919882096485172, 0.286321558035636, 
0.0617280881660506, 0.377634993440803, 0.353887387522467)), row.names = c(NA, 
-34L), class = c("tbl_df", "tbl", "data.frame"))

Solution

  • [Couldn't post snapshot in comment--sorry]

    Actually when I ran your data in RMarkdown it output to PDF just fine with the arrows as desired [screen shot snippet of output]: enter image description here

    Here's entirety of code I used:

    ```{r}
    library(flextable)
    
    Q <- structure(list(something = c("A→B", "A→B", "A→B", "A→B", 
    "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", 
    "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", 
    "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", 
    "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", "A→B", 
    "A→B", "A→B"), A = c(50.0368835409195, 49.9992842206918, 
    50.1838394874486, 50.1176549507243, 50.1010529015179, 49.821713095517, 
    50.0698654258166, 49.9023807785062, 50.1478052632896, 49.8474946541399, 
    50.125583771611, 50.0245256592517, 49.9639619226328, 49.9672433460124, 
    49.9281524409641, 49.9795056995374, 49.7792220695405, 49.9358849340944, 
    50.1172137552123, 49.7111044156362, 50.2921556948872, 50.0169633926026, 
    50.0273607894839, 50.1207597292804, 49.9860929016013, 50.0713408270736, 
    49.6186835491455, 49.9844826925892, 50.2323684845959, 49.9898805063105, 
    50.0992891050281, 49.5389082649178, 50.1812597290405, 49.7834578109085
    ), B = c(50.1776428964591, 50.1813031157202, 50.1927613652949, 
    50.1679213933357, 50.1569243982301, 50.1233335529302, 50.1749893807647, 
    50.1549162541763, 50.1635921809174, 50.146455542177, 50.1054992604603, 
    50.1039886051106, 50.0762789780625, 50.0330009165502, 50.0410459608984, 
    50.0267687312948, 50.2259333568155, 50.0656668738789, 50.2259846449786, 
    50.3278126226738, 50.1020984124345, 50.0134973819586, 50.040087658563, 
    50.0505477459729, 50.1863603001512, 50.2375471508255, 50.2412852792546, 
    50.1805273383299, 50.1344685033523, 50.1002066667137, 50.0923566514067, 
    50.2417689993628, 50.2035852184223, 50.2314878531161), C = c(109, 
    111, 109, 110, 112, 115, 111, 111, 111, 113, 114, 114, 114, 115, 
    115, 115, 104, 114, 109, 77, 115, 115, 115, 115, 100, 104, 101, 
    104, 115, 113, 115, 105, 99, 102), D = c(0.207627446155601, -0.00394797025625418, 
    0.953715425118201, 0.700654921848441, 0.643959146300284, -1.44556692195395, 
    0.399255232010291, -0.630141891907051, 0.903498336294232, -1.04130812390698, 
    1.19037584778399, 0.235849487793271, -0.472450972502978, -0.992598309740363, 
    -1.75041727525403, -0.765605969026731, -0.977181650250334, -0.97636848106905, 
    0.518680175033174, -0.881282673032435, 2.86151065350567, 1.25679132846729, 
    0.682524010248754, 2.38902303072274, -0.074624790727555, 0.300322806759241, 
    -1.58035522114156, -0.0859554433937029, 1.72805139347118, -0.100986231967636, 
    1.07506176886905, -1.9071582225074, 0.890338357790617, -0.935436508553472
    ), E = c(0.836234883045752, 0.996862866711249, 0.344118897285272, 
    0.486226704786596, 0.52197709148008, 0.153103083617026, 0.691099560247056, 
    0.530955270501434, 0.369815705614773, 0.301712272900562, 0.238295447393385, 
    0.814302587703858, 0.638212051791818, 0.324586542757989, 0.0847649462526957, 
    0.446681990016779, 0.332836775303587, 0.332558097391966, 0.6059238027773, 
    0.385942947438544, 0.00566597171300206, 0.213326881710713, 0.497332936024347, 
    0.0198050427456018, 0.94081101668899, 0.765084106174977, 0.120208357693328, 
    0.931819756960404, 0.088727413048962, 0.919882096485172, 0.286321558035636, 
    0.0617280881660506, 0.377634993440803, 0.353887387522467)), row.names = c(NA, 
    -34L), class = c("tbl_df", "tbl", "data.frame"))
    
    flextable(Q)