Code Monkey home page Code Monkey logo

r2excel's Introduction

r2excel

r2excel is an R package containing an easy to use functions to read, write and format excel files (Excel 2007 and Excel 97/2000/XP/2003).

Installation

install.packages("devtools")
library(devtools)
install_github("kassambara/r2excel")

Geting started

Find out more at http://www.sthda.com/english/wiki/r2excel/

r2excel's People

Contributors

kassambara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

r2excel's Issues

Expand column width in sheet and my code is very clunky

I am exporting some code to excel using your very helpful package, and trying to do it to 1 workbook over 3 sheets. However to do this I have repeated each command thrice, this can't be a good way to do it? Where am I going wrong? In addition, while the reprex below shows very short numerical observations, in reality the first column of my table needs to be much wider than the others, as it has a lot of text (while the rest don't). Is there a way to set this, or do i need to drag it across when I open the excel file? Thanks so much!

library(r2excel)
#> Loading required package: xlsx

 sample_prime1 <- 1:4
 sample_prime2 <- 10:14
 sample_prime3 <- 22:26
# Create an Excel workbook. 
filename <- "validitycheck.xlsx" #The name of the file that will be saved
wb <- createWorkbook(type="xlsx") #Creating an excel workbook

# Create a sheet in that workbook to contain the data table
sheet1 <- createSheet(wb, sheetName = "prime1")
sheet2 <- createSheet(wb, sheetName = "prime2")
sheet3 <- createSheet(wb, sheetName = "prime3")
 

# Add table : add a data frame for sheet 1
xlsx.addHeader(wb, sheet1, value="Validty for prime 1")
xlsx.addLineBreak(sheet1, 1)
xlsx.addTable(wb, sheet1, sample_prime1,
               fontColor="darkblue", fontSize=14,
              rowFill=c("white", "lightblue"),
              startCol=2, 
              row.names=FALSE, 
              col.names = FALSE)

# Add table : add a data frame for sheet 2
xlsx.addHeader(wb, sheet2, value="Validty for prime 2")
xlsx.addLineBreak(sheet2, 1)
xlsx.addTable(wb, sheet2, sample_prime2,
               fontColor="darkblue", fontSize=14,
              rowFill=c("white", "lightblue"),
              startCol=2, 
              row.names=FALSE, 
              col.names = FALSE)


# Add table : add a data frame for sheet 3
xlsx.addHeader(wb, sheet3, value="Validty for prime 3")
xlsx.addLineBreak(sheet3, 1)
xlsx.addTable(wb, sheet3, sample_prime3,
               fontColor="darkblue", fontSize=14,
              rowFill=c("white", "lightblue"),
              startCol=2, 
              row.names=FALSE, 
              col.names = FALSE)

Problem Installing and Loading r2excel

> install_github("kassambara/r2excel")
Downloading GitHub repo kassambara/r2excel@master
✔  checking for file ‘/private/var/folders/w5/l4gkl0p93wbgch51gnq7khm00000gn/T/RtmpHsU9t7/remotes36766a7fa1aa/kassambara-r2excel-4144fc5/DESCRIPTION’ ...
─  preparing ‘r2excel’:
✔  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘r2excel_1.0.0.tar.gz’
   
* installing *source* package ‘r2excel’ ...
** R
** byte-compile and prepare package for lazy loading
Error: package or namespace load failed for ‘xlsx’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/server/libjvm.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
  Reason: image not found
Error : package ‘xlsx’ could not be loaded
ERROR: lazy loading failed for package ‘r2excel’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/r2excel’
Error in i.p(...) : 
  (converted from warning) installation of package ‘/var/folders/w5/l4gkl0p93wbgch51gnq7khm00000gn/T//RtmpHsU9t7/file367627cccca3/r2excel_1.0.0.tar.gz’ had non-zero exit status
> library(r2excel)
Error in library(r2excel) : there is no package called ‘r2excel’

Add paragraph after add a table doens't work

Hello.

I'm trying to create an excel sheet using r2excel package.

But when I try to add a paragraph at the end of the sheet, after adding a table, it doesn't shows up.

The lines and columns set to merge appears correctly but none value is shown.

Could you fix it. please?

Thanks

addHeader Not Found

Hi,

I copied and pasted your code in order to test it out on my instance of RStudio but continue to get a "could not find function "xlsx.addHeader"". Is there something wrong with the code or R? I'm fairly new to R so perhaps the answer is fairly simple, but thought I'd check in.

backGroundColor doesn't work

At first thanks a lot for this amazing package.
library("r2excel")
filename <- "r2excel-example1.xlsx"
wb <- createWorkbook(type="xlsx")
sheet <- createSheet(wb, sheetName = "example1")
xlsx.addHeader(wb, sheet, "Add paragraph", level=2)
paragraph="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged."
xlsx.addParagraph(wb, sheet, paragraph, fontSize=14, isItalic=TRUE, fontColor="darkred", backGroundColor="gray")
saveWorkbook(wb, filename)

bachGroundColor doesn't work. Maybe this information is necessary: I'm running on linux mint 18 and use libreoffice.

Java Issue

I have been trying to install this package to R and have been getting the following error:
`devtools::install_github("kassambara/r2excel")
Downloading GitHub repo kassambara/r2excel@master
from URL https://api.github.com/repos/kassambara/r2excel/zipball/master
Installing r2excel
"C:/PROGRA1/R/R-341.4/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL
"C:/Users/rawlingsD/AppData/Local/Temp/Rtmpikoahr/devtools34bc39bb1506/kassambara-r2excel-4144fc5"
--library="C:/Users/rawlingsD/Documents/R/win-library/3.4" --install-tests

  • installing source package 'r2excel' ...
    ** R
    ** preparing package for lazy loading
    ** help
    *** installing help indices
    converting help for package 'r2excel'
    finding HTML links ... done
    getOS html
    r2excel-package html
    xlsx.addHeader html
    xlsx.addHyperlink html
    xlsx.addLineBreak html
    xlsx.addParagraph html
    xlsx.addPlot html
    xlsx.addTable html
    xlsx.openFile html
    xlsx.readFile html
    xlsx.writeFile html
    xlsx.writeMultipleData html
    ** building package indices
    ** testing if installed package can be loaded
    *** arch - i386
    Error: package or namespace load failed for 'rJava':
    .onLoad failed in loadNamespace() for 'rJava', details:
    call: inDL(x, as.logical(local), as.logical(now), ...)
    error: unable to load shared object 'C:/Users/rawlingsD/Documents/R/win-library/3.4/rJava/libs/i386/rJava.dll':
    LoadLibrary failure: %1 is not a valid Win32 application.

Error : package 'rJava' could not be loaded
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'

  • removing 'C:/Users/rawlingsD/Documents/R/win-library/3.4/r2excel'
    In R CMD INSTALL
    Installation failed: Command failed (1)`

However, I have rJava being used for package xlsx, so I am unsure what the real issue is, just wanted to flag it to see if you know the way to get around this error?

Thanks in advance

errors from installation

Hi

Can someone help me for the installation errors? I have window 10 and just installed the new JAVA but still cannot install this package. Thanks!

library(devtools)
install_github("kassambara/r2excel")
Downloading GitHub repo kassambara/r2excel@HEAD
√ checking for file 'C:\Users\Ake\AppData\Local\Temp\Rtmps3rXmw\remotes60206955698e\kassambara-r2excel-4144fc5/DESCRIPTION' ...

  • preparing 'r2excel':
    √ checking DESCRIPTION meta-information ...
  • checking for LF line-endings in source and make files and shell scripts
  • checking for empty or unneeded directories
  • building 'r2excel_1.0.0.tar.gz'

Installing package into ‘C:/Users/Ake/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)

  • installing source package 'r2excel' ...
    ** using staged installation
    ** R
    ** byte-compile and prepare package for lazy loading
    Error: (converted from warning) package 'xlsx' was built under R version 3.6.3
    Execution halted
    ERROR: lazy loading failed for package 'r2excel'
  • removing 'C:/Users/Ake/Documents/R/win-library/3.6/r2excel'
    Error: Failed to install 'r2excel' from GitHub:
    (converted from warning) installation of package ‘C:/Users/Ake/AppData/Local/Temp/Rtmps3rXmw/file60207f9360fa/r2excel_1.0.0.tar.gz’ had non-zero exit status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.