On Nov 17, 2010, at 16:37 , Graves, Gregory wrote:
Follows is the exact solution to this:
v - NULL
#note that decreasing is FALSE so preceding year preceeds
for(i in 2:46) {
kk - melt(yearmonth[, c(1, i, i+1)], id.vars=month, variable_name=year)
v[[i-1]] - kk[order(kk$year,
On Wed, Nov 17, 2010 at 10:37 AM, Graves, Gregory ggra...@sfwmd.gov wrote:
Follows is the exact solution to this:
v - NULL
#note that decreasing is FALSE so preceding year preceeds
for(i in 2:46) {
kk - melt(yearmonth[, c(1, i, i+1)], id.vars=month, variable_name=year)
v[[i-1]] -
one approach is the following:
# say 'Data' is your data frame
DataNew - reshape(Data, direction = long, varying = list(2:length(Data)))
DataNew$year - rep(2000:2009, each = 12)
DataNew
I hope it helps.
Best,
Dimitris
On 11/17/2010 3:03 PM, Graves, Gregory wrote:
I have a file, each column
Dear Gregory,
Is there an easier, cleaner way to do this? Thanks.
There are of course several ways...
(assuming yearmonth to be a data.frame)
--- 1 ---
year - colnames (yearmonth) [-1]
year - gsub (^[^[:digit:]]*([[:digit:]]*[^[:digit:]]*$), \\1, year)
year - as.numeric (year)
month -
Hi Gregory,
is this what you want? Ok, not the most elegant way...
# using 'melt' from the 'reshape' package
library(reshape)
Data - data.frame(month = 1:12,
x2002 = runif(12),
x2003 = runif(12),
x2004 = runif(12),
x2005 =
Management District
Phones: DESK: 561 / 682 - 2429
CELL: 561 / 719 - 8157
-Original Message-
From: Patrick Hausmann [mailto:patrick.hausm...@uni-bremen.de]
Sent: Wednesday, November 17, 2010 9:49 AM
To: r-help@r-project.org; Graves, Gregory
Subject: Re: [R] stacking
-Original Message-
From: Patrick Hausmann [mailto:patrick.hausm...@uni-bremen.de]
Sent: Wednesday, November 17, 2010 9:49 AM
To: r-help@r-project.org; Graves, Gregory
Subject: Re: [R] stacking consecutive columns
Hi Gregory,
is this what you want? Ok, not the most elegant way
On Nov 17, 2010, at 10:37 AM, Graves, Gregory wrote:
Follows is the exact solution to this:
v - NULL
#note that decreasing is FALSE so preceding year preceeds
for(i in 2:46) {
kk - melt(yearmonth[, c(1, i, i+1)], id.vars=month,
variable_name=year)
v[[i-1]] - kk[order(kk$year,
8 matches
Mail list logo