R language:grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, invalid input 'x坐标' in 'utf8towcs'

Viewed 309

My IDE

Jetbrains DataSpell

My R Version

R 4.0.2

My R code

I used Chinese in the parameter "xlab"

x <- -6:6
y <- x^3
library("ggplot2")
qplot(x,y, xlab = "x坐标") 

Error

I used the qplot() function of the R language and encountered the following errors:

grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, 中的错误 (DataFrames.R#23): invalid input 'x坐标' in 'utf8towcs'

When I change the Chinese in the parameters to English, It will become normal

I seem to have found some problems, I can use Chinese parameters on RGUI and RStudio, and I can assign Chinese to variables without any errors, but on Jetbrains DataSpell IDE there are always errors

1 Answers

After putting space after x and the Chinese characters every thing goes correct see :

library("ggplot2")

x <- -6:6
y <- x^3
qplot(x,y, xlab = "x 坐标")

Created on 2022-05-29 by the reprex package (v2.0.1)

Related