特殊字符问题? utf8towcs错误。如何解决?

时间:2020-06-05 12:30:20

标签: r ggplot2 charts

我不知道该股票发生了什么。

几天前有效。但是今天不显示图表,只给我这个错误代码:

Warning messages:
1: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  invalid input 'Aín' in 'utf8towcs'
2: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  invalid input 'Aín' in 'utf8towcs'


"Aín" its a town in the .csv   I don´t know how to fix this....

这是代码:

library(tidyverse)

library('data.table') 




dfcsv <- read.csv("https://dadesobertes.gva.es/dataset/15810be9-d797-4bf3-b37c-4c922bee8ef8/resource/8ab99a46-1d04-42b4-8ee4-0cc5821be976/download/2020-06-05_casospormunicipio.csv", encoding = "UTF-8", header = TRUE, sep = ";")
colnames(dfcsv) <- c("code","Municipio", "PCR", "Tasa PCR", "PCR14", "Tasa PCR14", "Muertos", "Tasa Muertos")


dfcsv %>%
  mutate(Municipio = fct_reorder(Municipio, PCR)) %>%


  ggplot(aes(x=Municipio, y=PCR)) +
  geom_bar(stat="identity", width=0.6) + coord_flip() 

1 个答案:

答案 0 :(得分:1)

enter image description here

将编码更改为ASCII即可。