Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions R/TileDBArray.R
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,10 @@ setMethod("[", "tiledb_array",
colnames(res) <- allnames

## reduce output if extended is false, or attrs given
if (!x@extended || length(sel) > 0) {
res <- res[, if (sparse) allnames else attrnames]
if (!x@extended) {
if (length(sel) > 0) {
res <- res[, if (sparse) allnames else attrnames]
}
k <- match("__tiledb_rows", colnames(res))
if (is.finite(k)) {
res <- res[, -k]
Expand All @@ -617,6 +619,10 @@ setMethod("[", "tiledb_array",
}

if (x@as.matrix) {
k <- match("__tiledb_rows", colnames(res))
if (is.finite(k)) {
res <- res[, -k]
}
if (ncol(res) < 3) {
message("ignoring as.matrix argument with insufficient result set")
} else if (!is.null(i)) {
Expand Down
6 changes: 3 additions & 3 deletions inst/examples/ex_1.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ create_array <- function(uri) {


write_array <- function(uri) {
data <- list(array(seq(1:50), dim = c(10,5)),
array(as.double(seq(101,by=0.5,length=50)), dim = c(10,5)),
array(c(letters[1:26], "brown", "fox", LETTERS[1:22]), dim = c(10,5)))
data <- list(a=array(seq(1:50), dim = c(10,5)),
b=array(as.double(seq(101,by=0.5,length=50)), dim = c(10,5)),
c=array(c(letters[1:26], "brown", "fox", LETTERS[1:22]), dim = c(10,5)))
## Open the array and write to it.
A <- tiledb_array(uri = uri)
A[] <- data
Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test_dataframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ expect_equal(irisdf, newdf[,-1])


## test attrs subselection
arr <- tiledb_array(uri, as.data.frame=TRUE,
arr <- tiledb_array(uri, as.data.frame=TRUE, extended=FALSE,
attrs = c("Petal.Length", "Petal.Width"))
newdf <- arr[]
expect_equal(iris[, c("Petal.Length", "Petal.Width")], newdf)
Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test_tiledbarray.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ dat <- readRDS(system.file("sampledata", "bankSample.rds", package="tiledb"))
dir.create(tmpuri <- tempfile())
fromDataFrame(dat[,-1], tmpuri)

arr <- tiledb_array(tmpuri, as.data.frame=TRUE)
arr <- tiledb_array(tmpuri, as.data.frame=TRUE, extended=FALSE)
expect_true(length(attrs(arr)) == 0)

sels <- c("age", "job", "education", "duration")
Expand Down