Assigning one or more values to a vector/matrix/array x for which length(x) == 0 gives no error, e.g.
> x <- integer(0) > x[] <- 1:2 > x <- matrix(nrow=0, ncol=1) > x[] <- 1:2 > x[,1] <- 1:2 > x <- array(dim=c(0,1,1)) > x[] <- 1:2 > x[,1,1] <- 1:2 whereas > x <- integer(1) > x[] <- 1:2 Warning message: In x[] <- 1:2 : number of items to replace is not a multiple of replacement length > x <- matrix(nrow=1, ncol=1) > x[] <- 1:2 Warning message: In x[] <- 1:2 : number of items to replace is not a multiple of replacement length > x[,1] <- 1:2 Error in x[, 1] <- 1:2 : number of items to replace is not a multiple of replacement length > x <- array(dim=c(1,1,1)) > x[] <- 1:2 Warning message: In x[] <- 1:2 : number of items to replace is not a multiple of replacement length > x[,1,1] <- 1:2 Error in x[, 1, 1] <- 1:2 : number of items to replace is not a multiple of replacement length Is this intended by design or is it a bug that should be reported? /Henrik ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel