Exporting CSV from R, not being read by program until saved by excel - r

I'm exporting CSV files from R, using write.csv
I've also tried various encoding options.
The CSV files open fine and read manually.
However, I need to process these files in another program (METAL https://genome.sph.umich.edu/wiki/METAL) and the program is pretty much unable to recognize the text in the files.
But, when I open the CSV files in excel, and save them again manually with excel-- same name, same place, same encoding, without changing anything except clicking save as CSV, then METAL is able to recognize the text in the CSV files.
I was wondering if anyone has any suggestions how to fix this? It's very cumbersome to go in each file and have to re-save manually.

Related

How to open mht file via R?

I met a problem to open mht files in R. There is an approach in which first I need to open it in Excel then save as .xlsx and after that read it in R.
But this way doesn't correspond to my requirements as soon as I need the program which must work automatically (no manual work needed).
But unfortunately I didn't found in the Internet how to do this.
Can someone advise me the way in which I can open file with mht format with some data in R?

How to fill an excel file using R, while in the excel file

I'm trying to access an R script via an Excel file. That is, while I'm still in the Excel file, I'd like to run an R script, that fills that same Excel file. The reason for this is that Excel is not computationally efficient enough.
Now I know that normally, you're not able to fill an Excel file via R script when the Excel file is opened. My question is, is there a way to work around this? For instance, by letting the R script close, fill and then open the Excel file I'm calling the script from?
Any help would be much appreciated

Exporting csv using excel into R

I hope someone can help me solve the problem I am currently facing with excel. I have been trying to export a csv file I wrote in Excel Ver 16 into R studio but it keeps giving the "incomplete final line found by readTableHeader on 'Book1.csv'" error. I have included the screen shot of the error and the files I had used for this. This doesnt seem to happen for the other data set I downloaded directly from Kaggle called "adult-test.csv" though.
I have tried everything from reinstalling R, R studio, Excel, I even resorted to using Google Sheets and it still doesn't work. If anyone knows what I am doing wrong please do help!
Image of my R studio code
Picture of the csv file I am failing to read
Hard to guess here.
Sometimes Excel saves csv files incorrectly - even though cells below your table are empty Excel saves them in the csv because maybe in the past, there was something written in there.
So, here is a suggestion
Maybe try to read the Excel file directly, not save it first as a csv. You can do that for example with read.xlsx() from the openxlsx package.
If that does not help, please open the csv file with a text editor (not with Excel again). You will then be able to see the actual problem and if necessary, post the text here (instead of the Excel screenshot)

R Copying to and Reading from csv Files

When I go to save Excel data that I've pasted into a .csv file, I get a formatting issue and often the saved file has all the numbers in each row as one long string.
My read statement is
resids<-read.csv("C:\\Projects\residuals_Parts3.csv",header=TRUE)
Any ideas on how to fix this?
The warning you are getting is fairly standard in Excel - any formatting you've added to the file (e.g. widening columns) will get lost if you don't save the file as an excel file.. and the warning is supposed to remind you of this. Personally, the extra click or two annoys me too.
If you would like to avoid converting excel files to CSV before bringing them into R, try the openxls package. It's saved me from a lot of that monkey business.

Flex: Write data to file to open in Excel

I have a Flex application with a couple of DataGrids with data. I'd like to save the data to a file so that the user can keep working with them in Excel, OpenOffice or Numbers.
I'm currently writing a csv file straight off, which opens well in OpenOffice or Numbers, but not in Excel. The problem is with the Swedish characters ÅÄÖ, which turn up as other characters when opening in Excel. Converting (in Notepad++) the csv-file to ANSI encoding makes the ÅÄÖ show up correctly in Excel.
Is there any way to write ANSI-encoded files straight from Flex?
Any other options for writing a file that can be opened in Excel and OpenOffice?
(I've looked at the as3xls library, but according to the comments those files cannot be opened in OpenOffice)
Using the writeMultiByte function from the ByteArray class allows you to specify a character set. See :
http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/utils/ByteArray.html#writeMultiByte%28%29
There is also the option of the as3xls package at http://code.google.com/p/as3xls/. I like this as it comes out as a straight excel file that can also be easily opened in open office as well.

Resources