如何在使用R xlsx、readColumns时避免错误的浮点表示
我使用xlsx包readColumns()读取R中的数据。列中有不同的数据类型(字符和数字),因此我必须设置colClasses=“character” 我使用(例如)如何在使用R xlsx、readColumns时避免错误的浮点表示,r,xlsx,R,Xlsx,我使用xlsx包readColumns()读取R中的数据。列中有不同的数据类型(字符和数字),因此我必须设置colClasses=“character” 我使用(例如) wb wb <- loadWorkbook(file) sheets <- getSheets(wb) sheet <- sheets[["Tab1"]] rows <- getRows(sheet, rowIndex = 121:126) cells <- getCells(rows, colI
wb
wb <- loadWorkbook(file)
sheets <- getSheets(wb)
sheet <- sheets[["Tab1"]]
rows <- getRows(sheet, rowIndex = 121:126)
cells <- getCells(rows, colIndex = 6:10, simplify = TRUE)
x1 <- readColumns(sheet = sheet, startColumn = 6, endColumn = 10, startRow = 121,
endRow = 126, as.data.frame=TRUE, header=FALSE,
colClasses="character",
stringsAsFactors=FALSE)
x1 <- structure(list(X1 = structure(c(1L, 1L, 2L),
.Label = c("< 0,0001", "1.0E-4"), class = "factor"),
X2 = structure(c(1L, 1L, 2L),
.Label = c("< 0,0001", "2.0E-4"), class = "factor"),
X3 = structure(c(3L, 1L, 2L),
.Label = c("0.0023", "0.0044", "0.018600000000000002"),
class = "factor"),
X4 = structure(c(3L, 2L, 1L),
.Label = c("0.0044", "0.006", "0.0213"),
class = "factor"),
X5 = structure(c(3L, 1L, 2L),
.Label = c("0.0019", "0.0031000000000000003", "0.0147"),
class = "factor")), .Names = c("X1", "X2", "X3", "X4", "X5"),
row.names = c(NA, -3L), class = "data.frame")
x2 <- lapply(cells, getCellValue, keepFormulas=FALSE,
encoding="UTF-8")
x2 <- structure(list(`121.6` = "< 0,0001", `121.7` = "< 0,0001", `121.8` = 0.0186,
`121.9` = 0.0213, `121.10` = 0.0147, `122.6` = "< 0,0001",
`122.7` = "< 0,0001", `122.8` = 0.0023, `122.9` = 0.006,
`122.10` = 0.0019, `123.6` = 1e-04, `123.7` = 2e-04, `123.8` = 0.0044,
`123.9` = 0.0044, `123.10` = 0.0031), .Names = c("121.6",
"121.7", "121.8", "121.9", "121.10", "122.6", "122.7", "122.8",
"122.9", "122.10", "123.6", "123.7", "123.8", "123.9", "123.10"
))