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

问题描述 投票:0回答:1

我不知道这个脚本怎么了。

几天前还能用。但今天不显示图表,只给我这个错误代码。

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() 
r ggplot2 charts
1个回答
1
投票

enter image description here

将编码改为ASCII码,成功了。

© www.soinside.com 2019 - 2024. All rights reserved.