r-xlsx

read.xlsx and colClasses

纵然是瞬间 提交于 2021-02-07 13:17:52
问题 Does anyone know why argument colClasses does not seem to work in read.xlsx ? I create a sample *.xlsx file: > library(xlsx) > d1 = data.frame(A=LETTERS[1:3], B=letters[1:3], C=1:3, D=c(1.1, NA, NA)) > str(d1) 'data.frame': 3 obs. of 4 variables: $ A: Factor w/ 3 levels "A","B","C": 1 2 3 $ B: Factor w/ 3 levels "a","b","c": 1 2 3 $ C: int 1 2 3 $ D: num 1.1 NA NA > write.xlsx(d1, 'test.xlsx', sheetName='Sheet1', row.names=F, showNA=F) then try to read it with read.xlsx , without and with

read.xlsx and colClasses

若如初见. 提交于 2021-02-07 13:17:32
问题 Does anyone know why argument colClasses does not seem to work in read.xlsx ? I create a sample *.xlsx file: > library(xlsx) > d1 = data.frame(A=LETTERS[1:3], B=letters[1:3], C=1:3, D=c(1.1, NA, NA)) > str(d1) 'data.frame': 3 obs. of 4 variables: $ A: Factor w/ 3 levels "A","B","C": 1 2 3 $ B: Factor w/ 3 levels "a","b","c": 1 2 3 $ C: int 1 2 3 $ D: num 1.1 NA NA > write.xlsx(d1, 'test.xlsx', sheetName='Sheet1', row.names=F, showNA=F) then try to read it with read.xlsx , without and with

Use R to write multiple sheets in excel with dynamic sheetNames

前提是你 提交于 2021-02-05 11:25:08
问题 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 and answers on similar lines but couldn't find one that addressed naming sheets dynamically). I want to name the sheet by the name of the dataframe. For simplicity, I have named the dataframes in a pattern (say df1 to df10). How do I do this? Below is a reproducable example with my attempt with

Cannot open the file after writing xlsx file using R openxlsx package

人走茶凉 提交于 2020-01-04 03:50:34
问题 At first, I tried to read and write xlsx files in R (while comparing the output between the xlsx and openxlsx packages). I work on mac os. It worked well to read xlsx files using the read.xlsx() from both packages. However, when it comes to writing a new file, only the xlsx::write.xlsx() worked. To be more exact, the openxlsx::write.xlsx() command gave no error, and an xlsx file was successfully saved, but when I tried to open the file using Numbers (by double clicking on the file in the

Data import and text to column (when in excel A1 = 1+1+1 and 3 is visible)

ぐ巨炮叔叔 提交于 2019-12-11 05:49:40
问题 Let's say we have the excel file and in A1 we have formula = 1+1+1 . So excel shows 3 however you can do 'Text to Columns' and value 1 will be in A1, B1 & C1 . Is there anything we can do in R after data import (I use read.xlsx) to get the same result (1,1,1 as oppose to just 3)? Just to confirm, the original df is 1x1 with value 3 and the desired outcome is df 1x3 with 1 in all 3 cells. 回答1: Not the full answer, but should get you started. If we have this example file: We can use openxlsx

MemoryError in R while read.xlsx

不羁的心 提交于 2019-12-10 01:27:04
问题 I am using the following R code (that utilizes the Java parameter to increase memory as well): library(xlsx) options(java.parameters = "-Xmx1g") library(XLConnect) NiVe <- read.xlsx("version1.xlsx",1) The version1.xlsx file is 13 MB in size. I get the following error: Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.lang.OutOfMemoryError: Java heap space Can someone help? 回答1: Try to increase java Heap size(sufficient), by using: options(java.parameters = "

zipping up workbook failed. make sure tool is installed or zip application is available to R

不想你离开。 提交于 2019-12-08 11:33:40
问题 I am working with xlsx files and I want to create a Excel file but it failed. I am using openxlsx package. My code is given bellow. wb=createWorkbook() addWorksheet(wb,"first") writeData(wb,"first","Roll no",startCol = 1,startRow = 1) writeData(wb,"first","Name",startCol = 2,startRow = 1) writeData(wb,"first","1",startCol = 1,startRow = 2) writeData(wb,"first","alvi",startCol = 2,startRow = 2) saveWorkbook(wb,"first.xlsx",overwrite = TRUE) but i have found this error. Error: zipping up

using write.xlsx to replace an existing sheet with R package xlsx

百般思念 提交于 2019-12-07 01:46:52
问题 I am using package xlsx Version:0.5.7 Date: 2014-08-01. in R version 3.0.1 (2013-05-16) -- "Good Sport" Platform: i386-w64-mingw32/i386 (32-bit). I have an xlsx file with at least 2 sheets (say A and B). I need to read data from A, edit them and save them in B. This has to be done on a periodical base. I am able to read data from A with read.xlsx . After editing the data frame I want to save it in an existing sheet B in the same xlsx file. I try with this line write.xlsx(down, paste0(root,'

Timestamp changes when writing a R dataframe to an excel file depending upon UTC offset

心不动则不痛 提交于 2019-12-06 12:47:37
问题 I am trying to write a data frame into an excel file. The sample dataframe is as given below. As the timestamp is of class factor , I convert it into POSIXct format using the lubridate package. library(lubridate) library(xlsx) df=structure(list(ts = structure(c(5L, 8L, 9L, 1L, 6L, 7L, 4L, 2L, 3L), .Label = c("01.09.2016 10:56:56", "01.09.2016 11:04:37", "01.09.2016 12:03:59", "02.09.2016 08:47:01", "30.08.2016 08:27:28", "30.08.2016 16:08:56", "31.08.2016 07:38:43", "31.08.2016 10:26:53", "31

using write.xlsx to replace an existing sheet with R package xlsx

坚强是说给别人听的谎言 提交于 2019-12-05 06:07:36
I am using package xlsx Version:0.5.7 Date: 2014-08-01. in R version 3.0.1 (2013-05-16) -- "Good Sport" Platform: i386-w64-mingw32/i386 (32-bit). I have an xlsx file with at least 2 sheets (say A and B). I need to read data from A, edit them and save them in B. This has to be done on a periodical base. I am able to read data from A with read.xlsx . After editing the data frame I want to save it in an existing sheet B in the same xlsx file. I try with this line write.xlsx(down, paste0(root,'/registration reports/registration complete_WK.xlsx'), sheet="data_final", col.names=T, row.names=F,