Save Excel spreadsheet as .csv with R?

后端 未结 3 1714
星月不相逢
星月不相逢 2021-02-15 11:27

What is the simplest way to convert a large Excel spreadsheet with multiple worksheets into .CSV files in R?

Note that I\'ve tested XLConnect and XLSX and found that m

3条回答
  •  花落未央
    2021-02-15 11:52

    http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows

    EDIT: to address the read.xlsx option:

    If you have Perl running, you need a current version of gdata

    require(gdata)
    installXLSXsupport()   #now the example from help(read.xls)
        # load the third worksheet, skipping the first two non-data lines...
        if( 'XLSX' %in% xlsFormats() )  # if XLSX is supported..
          data <- read.xls(exampleFile2007, sheet="Sheet with initial text", skip=2)
     data
    #-----------------------
       X       X.1 D E.  F  G Factor
    1 NA  FirstRow 1 NA NA NA   Red 
    2 NA SecondRow 2  1 NA NA Green 
    3 NA  ThirdRow 3  2  1 NA   Red 
    4 NA FourthRow 4  3  2  1 Black 
    #------------------------
    write.csv(data)
    

    This was done on a Mac and up until this question I had always stumbled at the installXLSXsupport() stage since I always got an error. This time I started up Perl from a Terminal command line, and got success after first setting up my personal configuration, defining CPAN mirrors on my continent, and I left perl running.

提交回复
热议问题