I have converted a dataset I have in Excel using the pivot_wider function.
The idea was to reduce file size, which I believe I somewhat achieved (from 305k rows x 14 columns to 27k rows and 109 columns).
The problem is when I try to export the data frame to excel.
When I take a look at the data frame in R the values appear as correct (see picture 1).
However, when I open the excel file created from the write_xlsx formula, all values are missing in the newly columns (picture 2).
I used to export reports from R to Excel files with the *.xlsx file extension. However, I discovered there were differences in the same Excel file generated a few minutes later. I discovered this by running the code a second time and using File Compare in Windows Command Prompt. The differences were not apparent until you went out to about 16 decimal places. However, we have two people in different locations running the code and we wanted them to use File Compare to make sure each of them had identical files.
Since then I just export the files in CSV format. The CSV files are just as easy to open in Excel as XLSX files, and once opened in Excel can be saved in XLSX format.
The last time I wrote XLSX files from R was using the "openxlsx" package. I also had two other packages loaded, tidyverse and readxl. The code I run now to generate CSV files use the tidyverse package and the readxl package, but I don't think you need either one to write CSV files.
Here is an example of the code I use to write a CSV file using a data.frame named "map9" and saved to a file named "z_readin-3.csv".