how to save and close excel file in R using Shell() - r

I have an excel file that queries Olap cube using DAX.
For some unfortunate reasons with DBAs, this is currently only viable way for me to load cube data into R.
So I am trying to automatize opening, refreshing, and closing excel file using R script, instead of doing that manually.
After some web search, I am able to open the excel file using Shell(). And the excel file is set to refresh itself when it is opened.
What come's next is where I need help; I want to save this file (like Ctrl + S) and close it. So I can load it to my R.
#open excel file
shell.exec("zero_billed_cases.xlsx")
#save excel file
"How do I do this?"
#close excel file (this is what I found online, but this only opens the file)
shell('\"zero_billed_cases.xlsx\"')
Thanks for your time and effort!

Related

Open CSV data in tableau

I have had problems uploading the following file to Tableau:
https://www.kaggle.com/datasets/shivamb/netflix-shows/download
When loaded it looks like this
but loading it in R
Is it possible to load them in R and then by Rserve connect to tableau or is there a way to load them fine
Looks like a problem within the interpreter.
I can't download the file myself as I don't have a Kaggle account, and its not clear from you R screenshots, though you could adjust the text file properties to see if you can adjust how the interpreter works by right-mouse the object "netflix_titles.csv" in the data model window and selecting Text file properties from the context menu.
Another option would be to try to use the interpreter Usar el intérprete de datos
It looks like Tableau is reading this file as a Text file and not a CSV. Tableau should have multiple headers for every comma that it sees but your screenshot has a single column for the entire first row.
Sometimes, Tableau can correctly read the file if you check the "Use Data Interpreter" checkbox.
If you have trouble making that work, just simply open the CSV in Excel and save it as an XLSX. You could even connect to it via an import to Google Sheets if you don't have Excel.

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 from R, not being read by program until saved by excel

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.

excel and pc stuck freeze and bugged when openning files writen with r

i am writing excel files with an R script that read existing file run some formulas on it and then adding some columns to the original file and writing it as new file, but when i am opening the files in excel , i sometime get freezes and excel stuck , or even without opening excel my computer freeze a bit (for example file explorer not responsive)
i tried using write.csv , openxlsx and the xlsx libarry all bugged my computer a bit
EDIT: my files are pretty small something like 800X20 without any formulas only tables of numbers and letters they take about 100 kb, but i tried some functions for big files like write.xlsx2 which didn't help , i just have no idea what can impact on it im adding columns like that :
orgData["codes"]<-codes
time=rep(NA,length(orgData$codes))
time[1]=totalTime
orgData["totalTime"]<-time
right now i am using write.xslx from the openxslsx library like this :
orgData=orgData[,c("c1","c2",.....)]
orgData=analayze(orgData,name)
name=(paste(gsub('.{3}$',"",name),"xlsx",sep=""))
write.xlsx(orgData,file = paste("Out.",name),row.names = FALSE )

Resources