I need to export multiple dataframes to an existing excel file. I'm working in AWS and as stated in this post Can't upload xlsx library in Amazon Web Service, I can't use write.xlsx from the xlsx package.
Similar functions such as write_xlsx do not have the append function that allows me to export the dataframes in the existing file without overwriting it. Which function could be a substitute for write.xlsx? Thanks in advance! (Sorry for not providing any reproducible example, I didn't come up with any for this particular problem)
Related
I am trying to write to an excel file that needs to be uploaded somewhere. The target software creates an excel file which has an XML map attached to it. I recreated the entire file structure in R using code, but any time I try to write to that excel file, i think R actually deletes the old file and creates a new one instead, because the XML map is gone the moment I start writing any data to it. Loading up the workbook also doesn't seem to bring in the xml map, only the workbook data and sheets.
Is there a way to write data to this existing file within R (or python) without losing the XML map? Now i need to generate a file and manually copy paste the data into the other excel file.
I've been trying with xlsx, readxl, xml2 packages.
In the past Ive deal with a similar problem. To my knowledge, almost all the R packages that interact with excel replace the entire file with a new one. Except the openxlsx package. You can replace specific sheets, and range of cells, whitout touching the rest (data, styling , etc..). One last comment is that I dont know much about XLM maps, but maybe you are lucky.
Here is the vignette:
https://cran.r-project.org/web/packages/openxlsx/vignettes/Introduction.html
Hope it helps
I am trying to export a dataframe from R to excel. I am using the 'writexl' package but it does not seem to work.
The code is as following:
install.packages('writexl')
library(writexl)
write_xlsx(data_frame, "H:\\folder1.xlsx")
There does not seem to be any error produced and the code appears to have run, however when I look in 'folder1' the data_frame is not there.
Is there anything I am doing incorrectly?
I've found the openxlsx package to be easier to use than the xlsx package. It also doesn't have a java dependency. The main command for directly writing a data frame to an Excel file is write.xlsx. You can also create worksheets, do lots of fancy formatting and write multiple tables to a worksheet (see the vignettes here for some examples), but start with write.xlsx for the basic creation of Excel files.
I have some excel file with simple formulas like =SUM(A1:A3).
I need to import the file into R, but before that I need to refresh the formulas. Is there a way to refresh the file from within R? There are good packages for importing the data in a R dataframe (eg. the R xslx package) but I need to refresh my formulas first.
Any suggestions?
Thanks!
You should be able to do this with RDCOMClient:
library(RDCOMClient)
ex = COMCreate("Excel.Application")
book = ex$Workbooks()$Open("my_file.xlsx")
book$Worksheets("Sheet1")$Calculate() # if you have many sheets you could loop through them or use apply functions based on their actual names
book$Save()
book$Close()
Here's another thread on the underlying VBA
I'm wondering which package can be used in a Shiny App to export data to excel file.
I know I can use xlsx, but it requires RJava and I fear that other users can't install it.
you can easily export data to Excel using a download button and base R. Then your file would be a csv-file, which can be easily opened in Excel. An example could be:
https://shiny.rstudio.com/articles/download.html
Would a csv-File be sufficient or do you absolutely need an xlsx-file?
I am using the topmodel package in R with the huagrahuma dataset that comes with the package.
I would like to bring all these variables into excel, edit those as per my requirement & then use the base in R.
package & data: https://rdrr.io/cran/topmodel/man/huagrahuma.html
You can save datasets using a command like write.csv() or one of the writing functions from the readr, readxl or xlsx packages (for example). Using:
?write.csv()
Will show you how to use the function. Once you have it saved as a .csv file on your computer, you can open it with Excel and do what you need with it.
Edit: Following G5W's comment below, you could try extracting elements of this list and saving those, depending on what you actually want to change. To be honest, with a list structure, you are better off changing the data in R, using any of the apply family of functions, or the purrr package. R is much better than Excel for transforming/tidying data, so why not use it? :-)