I'm trying to make a plot using ggplot2 with data from a csv file with names that contain accents like, for example, "México"
The problem is that the outcome is a plot that replaces accents with other characters.
data <- read.csv("Vic102(2).csv", sep = ",", header = TRUE, encoding = "latin1")
data2 <- melt(data, id = "Pais")
ggplot(data2, aes(Pais, y = value , fill = variable)) + geom_bar() + coord_flip()
I have also tried
data <- read.csv("Vic102(2).csv", sep = ",", header = TRUE, encoding = "utf-8")
data2 <- melt(data, id = "Pais")
ggplot(data2, aes(Pais, y = value , fill = variable)) + geom_bar() + coord_flip()
On the y labels one reads: M<8e>xico or M.xico
I have also tried replacing the labels with no success:
data2$Pais[11]<-"México"
Warning message:
In `[<-.factor`(`*tmp*`, 11, value = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, :
invalid factor level, NA generated
I am using Rstudio with R version 3.0.0 and my computer is a MAC OS X 10.8.5
Thank you!