I have a vector in R that contains special characters, e.g. x = "Köln"
.
I have trouble exporting that back to either excel or csv format (preferably in Excel).
Here is what I tried:
#Exporting to excel
library(excel.link)
myExcelProcess = COMCreate("Excel.Application")
xl.workbook.add()
excelRange = myExcelProcess[["ActiveSheet"]]$Range("A1:A1")
xl.write(x, excelRange, row.names = FALSE) # this creates an excel file with "ruined" characters (KΓ¶ln)`
#Exporting to csv
write.csv(x = routesCities, file = "out.csv", fileEncoding = "UTF-8") # This creates a csv containing "Koln" - the Umlaut has disappeared.
Any help would be greatly appreciated.
EDIT (Regarding the flagging as possible duplicate): imho the question is rather different than the proposed duplicate, since it refers to encoding issues during data transfer between R and Excel, not failing to run a write.xlsx()
function. Furthermore, my attempts do not result in an error (there is no error message), but the results are not the desired ones. It might be the case that the same answer (using a different library) could apply here, too, but the question itself is quite different.