flextable icon indicating copy to clipboard operation
flextable copied to clipboard

The picture in Rstudio is displayed in Chinese - ragg need to be used

Open JTCDCTWB opened this issue 2 years ago • 6 comments
trafficstars

As a user of Officeverse,I am really grateful for your contributions!

Meanwhile, a BUG was found during application, that is after loading any package of "flextable", "officer" and "officedown", the images with Chinese characters could not be plotted into Chinese in Rstudio. If the images with Chinese characters was plotted first, then loading the above three packages, everything is OK.

R:4.3.1; Rstudio:2023.09.0 Build 463; Operating System:Win11(22H2) or Win10(LTSC 2019 21H2)

Looking forward to your reply at your earliest convenience.

library(tidyverse) library(flextable) library(officer) tibble(性别 = c("男","女"),人数 = c(69,59)) %>% ggplot(aes(性别,人数)) + geom_point()

1

Restart Rstudio

library(tidyverse) tibble(性别 = c("男","女"),人数 = c(69,59)) %>% ggplot(aes(性别,人数)) + geom_point() library(flextable) library(officer)

2

JTCDCTWB avatar Oct 13 '23 02:10 JTCDCTWB

hello,

What happen if you use ragg in RStudio default plot settings? Does it solve the issue?

Capture d’écran 2023-10-13 à 07 37 38

KR

davidgohel avatar Oct 13 '23 05:10 davidgohel

Thank you very much for your warm reply! According to your suggestion the problem was solved!

At 2023-10-13 13:38:23, "David Gohel" @.***> wrote:

hello,

What happen if you use ragg in RStudio default plot settings? Does it solve the issue?

KR

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

JTCDCTWB avatar Oct 13 '23 08:10 JTCDCTWB

*Thank you so much for your work!

Draw pictures in "officedown" with word exported in Chinese, sometimes the picture is not displayed, sometimes the Chinese is not displayed. The code is as follows:

output:

officedown::rdocx_document:



library(ggplot2)

df <- data.frame(性别 = c("男","女"),

                 人数 = c(48,45))

ggplot(df,aes(x = 性别,y = 人数,fill = 性别)) +

  geom_bar(stat = "identity")

1

2

Operating environment:

Windows 11 22H2

R version 4.3.1

Rstudio version 2023.09.0 Build 463

officedown version 0.3.1

The above problems have been reported to officedown

At 2023-10-13 13:38:23, "David Gohel" @.***> wrote:

hello,

What happen if you use ragg in RStudio default plot settings? Does it solve the issue?

KR

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

JTCDCTWB avatar Oct 19 '23 11:10 JTCDCTWB

What happen if you use ragg in knitr settings? Does it solve the issue?

knitr::opts_chunk$set(dev="ragg_png")

davidgohel avatar Oct 19 '23 11:10 davidgohel

Thank you!Problem solved.

JTCDCTWB avatar Oct 20 '23 00:10 JTCDCTWB

The issue (not solved or not documented yet) will need some work. Package 'ragg' is used by flextable, but I don't understand why it conflicts with your environment. This has already been reported. I will close the issue when it will be solved. Thank you for opening the issue!

davidgohel avatar Oct 20 '23 11:10 davidgohel