For the case someone is interested in it, here it is the solution
somebody suggested me: to use a list.
imp <- vector("list", 100)
imp[[1]] <- im[1:500,]
names(imp[[1]]) => the list of labels of imp[1:500,]
Thanks!
Federico
Federico Abascal wrote:> Dear all,
>
> it is likely a stupid question but I cannot solve it.
>
> I want to have a matrix of 100 elements.
> Each element must be a vector of 500 elements.
>
> If I do:
> imp<-array(dim=100)
> imp[1]<-vector(length=500)
> it does not work. Warning message: "number of items to replace is not
a
> multiple of replacement length"
>
> If I do:
> imp <- array(dim=c(100,500))
> and then fill imp:
> for(i in c(1:500)) {
> imp[i,] <- im[1:500,]
> #im[1:500,] is a vector of length 500, of class numeric. IT
> CONTAINS NAMES!
> }
>
> Now it works, but I loose the labels (names) associated to the original
> "im" variable.
> If I just do:
> j<- im[1:500,]
> I do not loose the labels.
>
> names(j) => list of labels
> names(imp[1,]) => NULL
>
> Any clue?
>
> Thanks in advance!
> Federico
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
>