Try this also:
reshape(cbind(Id = 1:8, DF), v.names = 'y', timevar = 'z', direction =
'wide', idvar = 'Id')[-1]
On Thu, Feb 25, 2010 at 10:17 AM, Juliet Ndukum wrote:
> I have a matrix, called data. I used the code below to rearrange the data
> such that the first column remains the same, but t
Hi:
Loop? We don't need no steeenking loop!! Here's a way to create a matrix
with matrix indexing that you can attach with x to create a new data frame.
Calling your original data frame df,
> m <- matrix(NA, nrow = nrow(df), ncol = 3)
# Create the indices of the initialized matrix to modify
> idx
I have a matrix, called data. I used the code below to rearrange the data such
that the first column remains the same, but the y value falls under either
columns 2, 3 or 4, depending on the value of z. If z=1 for example, then the
value of y will fall under column 2, if z=2, the value of y falls
3 matches
Mail list logo