1
I imported a file into . xls that contains columns with drug names and their class. Some names have accents like "Antipsychotic", "Benzodiazepine" and "Tricyclic Antidepressant". I used read.xlsx as below:
require(xlsx)
AskStack <- read.xlsx("file.xlsx",sheetIndex = 1)
And when I checked the date.frame I saw that the names were with encoding modifications as you see ahead:
> dput(AskStack)
structure(list(Medic.1 = structure(c(24L, 13L, 15L, 3L, 32L,
9L, 2L, 17L, 15L, 21L, 25L, 32L, 17L, 21L, 9L, 9L, 15L, 15L,
26L, 31L, 31L, 31L, 20L, 31L, 21L, 24L, 21L, 31L, 24L, 17L, 2L,
32L, 31L, 23L, 26L, 25L, 31L, 11L, 31L, 12L), .Label = c("alprazolam",
"Alprazolam", "Amitriptilina", "Bupropiona", "citalopram", "clomipramina",
"clonazepam", "Clonazepam", "Desvenlafaxina", "Diazepam", "Donarem",
"Donaren", "Duloxetina", "escitalopram", "Escitalopram", "fluoxetina",
"Fluoxetina", "fluvoxamina", "imipramina", "Imipramina", "Olanzapina",
"paroxetina", "Pondera", "Quetiapina", "Quetros", "Risperidona",
"Rivotril", "Sem uso informado", "sertralina", "Trazodona", "Venlafaxina",
"Venlaxin"), class = "factor"), classe = structure(c(2L, 4L,
4L, 1L, 5L, 5L, 3L, 4L, 4L, 2L, 2L, 5L, 4L, 2L, 5L, 5L, 4L, 4L,
2L, 5L, 5L, 5L, 1L, 5L, 2L, 2L, 2L, 5L, 2L, 4L, 3L, 5L, 5L, 4L,
2L, 2L, 5L, 4L, 5L, 4L), .Label = c("Antidepressivo TricÃclico",
"Antipsicótico", "BenzodiazepÃnico", "ISRS", "ISRSN", "não se aplica"
), class = "factor")), row.names = c(NA, 40L), class = "data.frame")
How do I import without having to change manually after import?
Try to specify the
enconding
in functionencoding = "UTF-8"
. The problem must be out there.– Jorge Mendes