130 questions
0
votes
1
answer
39
views
How do I export a .xlsx file for SPEI calculated data
I have made SPEI values for a time series from 1987-2022 and I am trying to export these values corresponding with the year and month into an excel file - but the output file is not giving me the ...
2
votes
1
answer
74
views
How to hide NAs when using xlsx::saveWorkbook? [duplicate]
Suppose I have a workbook with some NAs in it:
df <- data.frame(a = 1:3, b = c(1, NA, NA), c = c(NA, 2, 3))
xlsx::write.xlsx(df, 'df.xlsx')
wb <- xlsx::loadWorkbook('df.xlsx')
I want the data ...
0
votes
1
answer
56
views
xlsx::write.xlsx() crashes on tibble with 2+ rows and row.names = F parameter
When I call xlsx::write.xlsx() on a tibble with 2+ rows it crashes:
df <- structure(list(`region name` = c("Reg 1", "Reg 2"),
`value` = c(1.38755717255717, ...
1
vote
0
answers
65
views
Read an Excel file which contains hyperlinks [duplicate]
I need to read an excel file into R.
I am using the following code:
library(readxl)
data <- read_excel("path/to/file.xlsx")
The Excel file looks like this:
I would like to read the file ...
1
vote
1
answer
186
views
Download.file keeping original name or sheet name
I want to download the following link in R keeping the file name after browser download.
http://www.coingecko.com/price_charts/export/1/usd.xls
Notice that the file name will be 'btc-usd-max.xls' if ...
1
vote
2
answers
136
views
How to combine columns of different excel files and renaming the column with the name of the initial file using R?
I have 96 different Excel files in a folder that all contain one single column, which looks approximately like this, whereby the uppermost line is the name of the Excel file:
A1.xlsx
Distance
245
534
...
0
votes
1
answer
130
views
R functions on workbook skipping blank cells
I'm trying to write a function that edits workbooks imported via loadWorkbook and have a problem where blank cells get ignored rather than treated as NAs. The following code demonstrates this issue.
...
0
votes
2
answers
122
views
Read different excel dataframes depending on selectInput Shiny
I have a shiny app that I would wish to pass data frames from different Excel files depending on the choice from a selectInput. I tried to use observeEvent and if...else statements as shown in the ...
1
vote
1
answer
108
views
Exporting several tibbles to separate sheets in excel
I'm looking for a way to automate some data clean-up. So far, I've figured out how to import several excel workbooks and all their sheets into R using the following:
my_data = expand_grid(
file = ...
0
votes
2
answers
299
views
Hide row with xlsx R package
I would like to hide a row in a dataframe that I am writing to Excel using the xlsx package, but can't find a way to do this.
xlsx has the option of
SheetName$setColumnHidden(index, TRUE)
is there no ...
4
votes
1
answer
1k
views
Date format issue while writing xlsx in R
Exp is a data frame , as given below:
> Exp
Branch Date Division
1 2 2023-02-10 820
2 2 2023-02-10 280
3 2 2023-02-10 935
4 2 2023-02-10 359
5 2 ...
0
votes
1
answer
131
views
How can I produce a column containing "values ± error" from two columns with one being "value" and the other being "error"?
I have raw data, output from a geochemical analysis, which contains a large number of observations for over 200 variables. The output of this analysis generates a number of columns containing many ...
1
vote
0
answers
449
views
Apple M1 - Cannot Load rJava for xlsx package in R
I am currently working on an assignment that requires me to utilize the xlsx package in R. I have installed both "xlsx" and "rJava" packages, and have installed the most recent ...
0
votes
0
answers
163
views
R crashes when install xlsx
When I try to install the package xlsx I get fatal error and R server session disconnected.
It shows both the bomb with fatal error and server session diconnected even though I am just running it ...
2
votes
1
answer
74
views
Split xlsx file into small files based on count of rows
I have a dataset with greater than 20000 rows which I can't import into SharePoint due to its total number rows upload limitation to 20000. There are 17 columns and each of them have 6694 rows ...
3
votes
0
answers
238
views
How to include file in shiny package?
I'm making a shiny app with golem, which automatically makes it a package and for some background calculations that happen before the user does anything I'm loading in an excel file (just with xlsx's ...
1
vote
1
answer
7k
views
Skip starting blank rows in Excel with XLSX in JavaScript Sheet-JS
I have the following code that works great when the header row is row 1
readerData(rawFile) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
...
2
votes
1
answer
52
views
How can i write systematic data into excel sheet with systematicly?
I have been working with big though systematic data. Therefore I have wrote only shape of my data frame to below. I need to write every 3 column into different excel sheet. I tried some code and ...
5
votes
2
answers
8k
views
R Session Aborted and R encountered a fatal error
I have been using Rstudio for a while and there was no problem until I was trying to install rJava and xlsx package in R. I had updated both my RGui and Rstudio to the latest version (also downloaded ...
0
votes
0
answers
251
views
i can't read an excel that i could already read in R, i'm using the tool read.xlsx2
I'm using R and i need to open an excel file, while i'm working with it it appears the next message:
Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/...
2
votes
0
answers
307
views
Getting Error while trying to read .csv in R Studio
I'm trying to import a dataset with .csv format but I keep getting errors.
If I use the built-in import feature of R Studio I get this error:
embedded nul in the string:
'C\0a\0m\0p\0a\0g\0n\0e\0_\0N\...
0
votes
0
answers
55
views
Is there a R function to add data from a df and append it to a sheet in excel
I have a R code that uses joins from various tables and finally have an output dataframe. I need this to be appended to a new worksheet in excel file that already has three sheets in it. I am on a mac ...
0
votes
1
answer
83
views
How can use variables for the row and columns in setCellFormula in the xlsx package in R?
I am trying to create a formula in a cell of an existing Excel document. I can easily do it this way:
#Load workbook
wb<-loadWorkbook('test.xlsx') #Let this be any xlsx document with borders on ...
0
votes
2
answers
1k
views
Read Excel file with highlighted cells using R
I have a lot of long Excel files and it is too hard to handle them manually. I'm reading them in R to identify the highlighted yellow cells as in the image
The objective: is to loop over the days ...
0
votes
1
answer
408
views
Reading xlsx with multiple sheets in R for duplication removal
I have a excel file which has multiple sheets embedded in it. My main goal is to basically remove all rows which are appearing multiple times in a single sheet and have to do this for every sheet.
I ...
0
votes
2
answers
708
views
How to write this dataframe to excel (xlsx)?
I have a dataframe of the following format:
What i want to do is write it to a .xlsx file as below (everything in one sheet):
Not fussed about the column names in the Excel file. Tried subsetting by ...
0
votes
2
answers
2k
views
How to append today's date into the filename to be saved as an Excel Workbook?
I have an R script that saves its output into an Excel Workbook.
library(stringr)
library(dplyr)
library(xlsx)
...
write.xlsx(as.data.frame(df31), file='df31.xlsx', sheetName="Sheet1", col....
1
vote
1
answer
140
views
Combining multiple worksheets from multiple excel workbooks into a single workbook via. R
Lets say I have two excel workbooks (e.g. A.xlsx and B.xlsx) that each contain multiple worksheets (e.g. "a1" and "a2" in A.xlsx; "b1", "b2", and "b3" ...
0
votes
1
answer
56
views
read a single *.xlsx file in R without the use of filename but utilizing the *.xlsx
I download an xlxs file everyday with a long unique name with dates each day. I need R to read the new xlsx file saved in the directory everyday without typing the unique name everyday. My idea is to ...
0
votes
1
answer
756
views
Adding a dataframe to a sheet without xlsx package
I'm currently using xlsx package to create and modify Excel files but I need to get rid of Java dependency. I've tried swapping the xlsx package for the openxlsx package but I can't find any simple ...
0
votes
2
answers
54
views
Exporting R 3 dataframes to 3 different sheets in the same excel workbook
I am attempting to export 3 dataframes to 3 different sheets in the same excel workbook, this is the code I used:
write.xlsx(x = df1,file = "Report.xlsx",sheetName = "pr1")
write....
0
votes
1
answer
825
views
R - Add text to merged cell using xlsx package
I have created a merged cell in an excel file using the xlsx package in R. I'd like to write text in this merged cell and have tried the code below, however this leaves the cell blank, with no text ...
3
votes
2
answers
10k
views
Although the xlsx package is installed in R, it does not work
Although the xlsx package is installed, it does not work.
I get the following error. What should I do? I use the latest version of R
install.packages("xlsx")
Installing package into ‘C:/...
2
votes
2
answers
3k
views
Use R to write multiple sheets in excel with dynamic sheetNames
This can easily be done using for loop but I am looking for a solution with lapply or dplyr.
I have multiple dataframes which I want to export to excel file in separate sheets (I saw many questions ...
0
votes
0
answers
443
views
using read.xlsx on R yield errors
I'm trying to run a line of code in R with read.xlsx taken from xlsx package.
it used to work fine but something has changed but I'm not sure what.
df_sheet <- xlsx::read.xlsx(lane_info, ...
1
vote
2
answers
1k
views
Loop to create multiple sheets in multiple Excel workbooks
I have a dataset with two different groups and their values, something like this:
example <- data.frame('Group' = c('building 1', 'building 1',
'building 2', '...
0
votes
1
answer
631
views
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 ...
1
vote
1
answer
547
views
read.xlsx2 | Skipping if sheetName does not exist
I am trying to read multiple excel files in a folder using the read.xlsx2 function. I only need to read a particular sheet titled 'Returns' or 'Prices'.
Is there a way I can give an 'OR' argument in ...
0
votes
1
answer
2k
views
R - Export data with English and Chinese words together to a CSV file
How can I export a data frame that has both English and Chinese words to a csv file? When I normally export it or even when I use a UTF-8 encoding to export the Chinese words are displayed as the ...
0
votes
1
answer
681
views
Writing data from for loop to one excel sheet
I'm trying to write data from my for loop to excel file in a way that the data is in one sheet. I've been using the xlsx library but for some reason adding the APPEND = TRUE doesn't do the trick. An ...
0
votes
1
answer
271
views
Remove space from exported filename in R using xlsx package
Trying to export a file using write.xlsx() from package "xlsx".
File export works as expected, however having trouble with the naming convention.
I wish for the file to be names as follows:
...
-1
votes
2
answers
3k
views
Write to a new sheet in a loop
My loop is completely doing what I want it to do apart from when writing out the data I want it to loop through and open a new sheet each time, it is not doing this but simply overwriting the data in ...
1
vote
0
answers
608
views
cannot install rJava on macOS Catalina 10.15.1
My mac system is macOS Catalina 10.15.1, and my R version is 3.6.1. When I try to install the rJava package on Rstudio using install.packages("rJava", type="source), it comes with error:
make: *** [...
2
votes
1
answer
1k
views
How to print top row in bold when writing dataframe to excel in R using write.xlsx
I write a dataframe in R to an excel file using the following command: write.xlsx(dataframe, pathName, row.names = FALSE, append = FALSE).
Now I want to print the first row (headers in the dataframe)...
1
vote
1
answer
846
views
Why does a question mark in a dataframe column title show as a period when outputting from r to an excel sheet (using xlsx package)?
Suppose I use the xlsx package to write a dataframe from r to excel. And suppose I have a dataframe with a column title that includes a question mark (code below):
library(xlsx)
rm(list = ls())
...
1
vote
2
answers
35
views
write to excel all non-zero-row dataframes in global environment
I have a set of empty (0-row) and non-empty (>0-row) Tibbles in my global environment and I want to select only the relevant ones, i.e. the non-empty ones and send them to a write.xlsx command.
It ...
0
votes
1
answer
734
views
How to deal with "Java Heap Space" error while running rjava
I am using rJava package in R on MacOS. This error happened:
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
java.lang.OutOfMemoryError: Java heap space
I need rJava to ...
1
vote
0
answers
358
views
R - xlsx package - add bottom border to set of rows
I'm using the "xlsx" package in R to read, modify and write a .xlsm file.
I'm having some problems with border styling to my rows and columns:
I'm adding a dataframe (df) into a sheet and I'm ...
1
vote
1
answer
772
views
Exporting multiple tibbles to XLSX -- sheetName problem when using deparse(substitute())
I have 15 tibbles that I want to export to a single XLSX workbook, with the sheetName for each set to be the same as the name of the tibble object. To export a single tibble, this works just fine:
...
1
vote
0
answers
148
views
how to give all borders and some colors in r while writing excel
I'm looking for examples or ideas on how I might display a data table in a. Rmd document that has grouped totals at multiple levels. So, in the example following, the date, names, qty, rate, and value ...