Hi there,

This is a problem I've run into and do not know how to avoid. It
happens when I make an assignment using the dimension names as the
subscript of the array. The end result is a dimenensionless array
(i.e. a vector) which I don't want. See:

> out <- array(0, 5, list(1:5))
> dim(out)
[1] 5
> out[names(out)] <- 1
> dim(out)
NULL

I tried to include a 'drop' argument into the index but it doesn't
seem to work:

> out[names(out), drop=FALSE] <- 1
Error in out[names(out), drop = FALSE] <- 1 : 
  incorrect number of subscripts on matrix

A solution would be to change the vector into an array myself, but I
would like to hear opinions before I do that, because I would rather
just make the assignment and keep the array object unchanged if such
thing is possible. Also, using a subscript of integers instead of
labels is not an option in this case.

Any help appreciated.

-- 
Cheers,
Ernest

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to