R : Export language error - r

I would like to export data to csv but my data language is not English. In R console they showed me correctly but when I exported to csv they showed in error (ex. £à¸¸à¸à¸•à¸¥à¸²à¸”หนัà¸à¸¡à¸²à¸ #รà) How can I fix this problem ?
Here is a code.
write.csv(tweetsDF, "/Users/mac/Documents/tweets.csv",fileEncoding = "UTF-8")
Thanks.

Related

Error during loading data frames (xlsx Format) in R

Good afternoon,
I’m currently working in R and importing data sets that have .xlsx format.
I use standard function read_excel.
For example:
MCC_1 <- read_excel("MCC_1.xlsx", guess_max = 500000, n_max = 500000)
Most of my files were imported correctly, however suddenly I faced with an error.
It is said: Error: expected ' or "
In a Traceback section I see this:
class = c("rapidxml::parse_error", "C++Error", "error", "condition")
Could you give me any ideas or even solutions of how to overcome it?
Thank you in advance!
Found a solution by myself!
All you have to do is to create a copy of your excel file to a new file. The problem stated appears when R is trying to read .xlsx files that were made automatically - for example during data unloading procedure from specific databases.

R read_excel from online web page link produces an empty data frame

Hi this is my first time posting,
I am trying to obtain data from an online web page link excel sheet. However,it works for the other links on the page but not a specific one which returns a blank data frame.
library(readxl)
download.file("https://www.parismou.org/sites/default/files/2016-04-DetentionLists_0.XLS","test.xls",mode="wb")
tbls=read_excel("test.xls")
Downloading it as a .xls file works fine but reading it doesnt work.
I have also tried using:
tbls=read.table("https://www.parismou.org/sites/default/files/2016-04-DetentionLists_0.XLS", header=TRUE, skipNul= TRUE)
which returns:
Error in read.table("https://www.parismou.org/sites/default/files/2016-04-DetentionLists_0.XLS", :
no lines available in input
I have also tried the XLConnect packages but those returned the following error:
require(XLConnect)
download.file("https://www.parismou.org/sites/default/files/2016-04-DetentionLists_0.XLS","test.xls",mode="wb")
tblspx=loadWorkbook("test.xls")
Error: OldExcelFormatException (Java): The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. POI only supports BIFF8 format (from Excel versions 97/2000/XP/2003)
Any help would be greatly appreciated.
You're dealing with a very old excel format. The gdata package can deal with that (see this SO post):
install.packages("gdata")
require(readxl)
download.file("https://www.parismou.org/sites/default/files/2016-04-DetentionLists_0.XLS","test.xls",mode="wb")
tbls = gdata::read.xls("test.xls", fileEncoding="latin1")

reading gctx file in R

I am trying to read a gctx file extracted from LINCS source for gene expression analysis. The codes for eading the file are provided at the link below.
https://github.com/cmap/l1ktools.
I am using the script provided and I have sourced the script. however when I tried the function parse.gctx it gives me following error:
ds <- parse.gctx("../L1000 Data/zspc_n40172x22268.gctx")
reading ../L1000 Data/zspc_n40172x22268.gctx
Error in h5checktypeOrOpenLoc(file, readonly = TRUE) :
Error in h5checktypeOrOpenLoc(). Cannot open file. File 'C:\L1000 Data\zspc_n40172x22268.gctx' does not exist.
How can I resolve this issue and read my gctx file?
Since you're getting a 'file does not exist' error, I think the problem is because you have a space in the path to the file you're trying to read (specifically, in "L1000 Data"); if you remove the space in the path it should parse properly.
In other words, try renaming your "L1000 Data" folder so that instead of:
ds <- parse.gctx("../L1000 Data/zspc_n40172x22268.gctx")
you have something along the lines of:
ds <- parse.gctx("../L1000_Data/zspc_n40172x22268.gctx")

Import dataset with spanish special characters into R

I'm new to R and I've imported a dataset in a CSV file format created in Excel into my project using the "Import Dataset from Text File" function. However the dataset displays spanish special characters (á, é, í, ó, ú, ñ) with the � symbol, as below:
Nombre Direccion Beneficiado
Mu�oz B�rbara H�medo
...
Subsequently I tried with this code to make R display the spanish special characters:
Encoding(dataset) <- "UTF-8"
And received the following answer:
Error in `Encoding<-`(`*tmp*`, value = "UTF-8") :
a character vector argument expected
So far I haven't been able to find a solution to this.
I'm working in Rstudio Version 0.98.1083, in Windows 7.
Thanks in advance for your help.

exporting data frame from R to excel

I have a large data frame(df). I want to export it as an excel file. I am using "WriteXLS" function from "WriteXLS" library. Everything is fine except for some non English characters. For "İ", "ı" and for some other characters a strange object(which is "�") is printed in the excel sheet. I guess it is an ecoding issue. The used code is:
WriteXLS("df", "C:/Users/ozgur/Desktop/df.xlsx",Encoding = "UTF-8", col.names = TRUE,perl = "perl")
The base exporting function
write.table(df, "C:/Users/ozgur/Desktop/df.txt", sep="\t",col.names=TURE)
does not work well. It does not convert data types as in R.
How can I overcome this problem. I will be very glad for any help. Thanks a lot.

Resources