Thanks A LOT guys for your posts and replying despite the fact that it might
have been a bit hard to get my point (I apologise for the latter).
Josh's and Jim's examples worked perfectly. A loop was certainly not the
most elegant solution.
What I want to do (for those who asked) is re-generate
Hi:
It's not immediately clear what you have in mind, as others have noted, but
here are a couple of ideas that seem as though they may apply to your
problem, as dangerous as it is to play clairvoyant:
I'm using vectors instead of a matrix, but the first vector, val, contains
the values whereas t
try this:
> x <- matrix(sample(25,25), 5)
> x
[,1] [,2] [,3] [,4] [,5]
[1,] 12 24 143 20
[2,] 2175 15 17
[3,] 11 10 22 169
[4,]6 2541 23
[5,]2 198 13 18
> # save result in a list
> result <- lapply(2:nrow(x), function(.row){
I do not follow. Could you please provide a small reproducible example
of what "table1" might look like, and what you want as a result?
Surely you don't need a for loop.
alfredo wrote:
Hi Everyone,
I have a 2-dim data.matrix(e.g., table1) in which row1 specifies a range of
values. row2 - row
Hi A,
Here is a little example that I believe does what you want. I am not
quite sure how you want all the output in a new matrix, because as you
repeat each value is the first row varying numbers of times, you will
not have rows of equal length. Although perhaps your data is setup so
that you c
Hi Everyone,
I have a 2-dim data.matrix(e.g., table1) in which row1 specifies a range of
values. row2 - rown specify the number of times I want to replicate each
corresponding value in row1. I can do this with the following function:
rep(c(table1[1,]),c(table1[X,])) #where X would go from 2 -
6 matches
Mail list logo