I tried to write a loop that would, say, return me a vector of ten numeric entries. It went well, until i attempted to label each element of the output generated by the block with another line. The naming is supposed to produce each entry with their unique label characters: "number"[n] where n is number in the sequence of repeats which was used in the generation of numeric vector.
multiples <- c()
i <- c(1:10)
for (n in i) {
print (n * 10)
multiples[n] <- n * 10
names(multiples)[n] <- "number"[n]
}
multiples
The execution is successful but the result is not what i'm expecting. Is there a way to name the elements correctly using the same for
loop?