From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David L
> Carlson
> Sent: Monday, November 28, 2016 8:27 PM
> To: jean-philippe ; r-help@r-project.org
> Subject: Re: [R] reshaping a large dataframe in R
>
> There may be a simpler way of getting there, but this work
On 11/28/2016 1:06 AM, jean-philippe wrote:
dear all,
I have a dataframe of 500 rows and 4004 columns that I would like to
reshape to a dataframe of 500500 rows and 4 columns. That is from this
dataframe:
V1 V2 V3 V4 ... V4001 V4002 V4003 V4004
1 2 3 4 ... 4001 4002 4003 4004
1 2 3 4 ... 4001
There may be a simpler way of getting there, but this works:
> rows <- 500
> cols <- 4004
> dat <- as.data.frame(t(replicate(rows, 1:cols)))
> dat[c(1:3, 500), c(1:4, 4001:4004)]
V1 V2 V3 V4 V4001 V4002 V4003 V4004
11 2 3 4 4001 4002 4003 4004
21 2 3 4 4001 4002 4003 4004
3 matches
Mail list logo