## Not run:
# scidbconnect()
# # A 1-d array representation as a data frame:
# data("iris")
# A <- as.scidb(iris)
# # Inspect the backing SciDB array object details with str:
# str(A)
#
# # Subsetting returns a new SciDB array:
# A[1:2,]
#
# # Materialize data to R with empty brackets:
# A[1:2,][]
#
# # Subset data frame-like object columns with 1-based positional or character
# # indices. The following are all the same:
# A[,"Species"]
# A$Species
# A[,5]
#
# # Represent the 1-d array as a vector-like object instead:
# a <- scidb(A, data.frame=FALSE)
# # Interrogate the SciDB array properties with str:
# str(a)
#
# # A matrix:
# set.seed(1)
# X <- as.scidb( matrix(rnorm(20), nrow=5) )
# # Diagonal entries of X:
# diag(X)
# # A sparse matrix with just the diagonal of X:
# D = diag(diag(X))
# # Materialize this sparse array to R:
# D[]
#
# # Produce a sparse matrix of filtered entries and materialize to R:
# subset(X, "val > 0")[]
#
# # Short-hand for the same effect:
# (X > 0)[]
#
# # Assign row labels to X. Note! We make sure that the index array starts at the
# # same starting index as the matrix (zero in this example):
# rownames(X) <- as.scidb(data.frame(letters[1:5]),start=0)
# # Index by label:
# X[c("c","a"), ]
#
# # Filter X by an auxillary SciDB array condition (we use the rownames array),
# # returning the result to R:
# X[rownames(X) > "'b'", ][]
#
#
# # A 3-d array:
# X <- build(dim=c(3,2,2),names=c("x","i","j","k"),data="i+j+k")
#
# # A sparse 3-d array filtered with subset:
# Y <- subset(X, "x>1")
# count(Y)
# Y[]
# ## End(Not run)
Run the code above in your browser using DataLab