Tag: gdata

用gdata将excel文件导入r,数据显示为'General'

library(gdata) xls_data = read.xls("C:/folder/data_that_i_want.xlsx", perl ="C:/Perl64/bin/perl.exe", sheet = "sheet_that_i_want")$column_name 当我试图看看r中的数据时,每个字段都是“General”,而不是我想要从Excel中获得的数字数据。

read.xls不按预期方式运行

我有一个像这样的Excel文件(xls格式) ab 10/06/2012 10/06/12 19:00 11/06/2012 11/06/12 05:30 11/06/2012 11/06/12 09:30 11/06/2012 11/06/12 10:00 11/06/2012 11/06/12 11:00 11/06/2012 11/06/12 11:30 我正在使用gdata库的read.xls函数将这个xls文件读入R. data <- read.xls("data.xlsx") 但是当在R中打开这个文件时,我得到了这个 ab 41070 41070.79 41071 41071.23 41071 41071.40 41071 41071.42 41071 41071.46 41071 41071.48 我不知道这里发生了什么事。 当我使用read.csv读取转换后的csv文件时,正在正确读取文件。 有人可以告诉我有什么问题吗? 我正在Linux机器上工作。

如何从Excel导入时忽略隐藏的数据

我有我正在导入到R的Excel文件的集合。 这些文件包含我想忽略的隐藏数据 – 例如,根本不导入它,或者用一个表示隐藏的标志导入它,然后我可以删除它。 这些文件包含两种types的隐藏数据: 完整的表是隐藏的 表单中的特定行是隐藏的。 有什么方法可以确定何时隐藏Excel中的数据? 现在我正在使用gdata包,但很高兴使用XLConnect或其他包 示例代码: library(gdata) xlsfile <- "test.xls" # grab all the sheet names. # This is giving me both hidden & non-hidden sheets. I would like only the latter sheets <- sheetNames(xlsfile) # read in the xls file, by sheet xlData <- lapply(sheets, function(s) read.xls(xlsfile, sheet=s, stringsAsFactors = […]

不可能在R中加载“Excel 5.0 / 7.0(BIFF5)格式”文件

有很多方法可以在R中加载Excel文件,如下所示: http : //www.milanor.net/blog/?p=779 但是,我已经尝试了大部分的选项(RODBC,xlsx,gdata,XLConnect),并且不能让R加载这个由英国政府在2013年发布的特定文件: http://www.ons.gov.uk/ons/rel/npp/national-population-projections/2012-based-projections/rft-table-a3-4-principal-projection—england-population-single-今年的-age.xls 以下是我尝试失败的一个例子: # save the file download.file("http://www.ons.gov.uk/ons/rel/npp/national-population-projections/2012-based-projections/rft-table-a3-4-principal-projection—england-population-single-year-of-age.xls", destfile = "input-data/future-pop-ons.xls") library(RODBC) XLConnect::readWorksheetFromFile(file = "input-data/future-pop-ons.xls", sheet = 3) ## Error: OldExcelFormatException (Java): The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. POI only supports BIFF8 format (from Excel versions 97/2000/XP/2003) library(XLConnect) XLConnect::readWorksheet("input-data/future-pop-ons.xls", sheet = 3) Error in (function (classes, fdef, […]

从Excel到R的平台依赖关系

我正在使用gdata导入xls文件。 我使用as.Date转换date列来转换date 根据as.Date的手册,date起源是平台相关的,所以我决定使用哪个起源 .origin <- ifelse(Sys.info()[['sysname']] == "Windows", "1899-12-30", "1904-01-01") as.Date(myData$Date, origin=.origin) 但是,我想知道是否应该考虑读取文件的平台或写入平台。 对于什么是值得的,我目前正在一个没有excel的Linux机器上testing代码,并且正确的date是通过使用origin="1904-01-01" 引用`?as.Date' ## date given as number of days since 1900-01-01 (a date in 1989) as.Date(32768, origin = "1900-01-01") ## Excel is said to use 1900-01-01 as day 1 (Windows default) or ## 1904-01-01 as day 0 (Mac default), but this is […]