Ivan  Terekh
Ivan Terekh

Reputation: 23

Error when drawing a graph in Rstudio on linux. invalid string in PangoCairo_Text

I am trying to perform PCA analysis with R running the following command:

> pca.earn <- PCA(earn, quanti.sup=j_act, ind.sup=i_act, scale=T)

PCA is from FactoMineR library.

Unfortunately I get the following error:

Error in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y,  : 
  invalid string in PangoCairo_Text

However, I don't get an error when I specify graph = FALSE. So, probably there is some problem with drawing a graph.

I am using Ubuntu 18.04 and R 4.0.

Do you have any idea of how can I fix this?

Upvotes: 2

Views: 1580

Answers (2)

Pumbaa
Pumbaa

Reputation: 100

In my case, @pathilink is correct. It's caused by non UTF-8 characters in the data. Converting all characters to UTF-8 with the following line fixed my error.

df %>% lapply(., iconv, to = "UTF-8") %>% tibble::as_tibble() %>% ...

Upvotes: 2

pathilink
pathilink

Reputation: 251

When encoding = "utf-8" is not being recognized, you can check if there is any text with a strange character. For example, change "José" to "Jose" in your database.

Upvotes: 0

Related Questions