On Fri, Feb 18, 2011 at 8:35 PM, Dennis Murphy wrote:
> Hi:
>
> Here's another approach using the reshape package:
>
> library(reshape)
> # id defines the grouping variables; the others are stacked, creating
> # new variables 'variable' (containing the variable names as factor levels)
> and
> # '
Hi:
Here's another approach using the reshape package:
library(reshape)
# id defines the grouping variables; the others are stacked, creating
# new variables 'variable' (containing the variable names as factor levels)
and
# 'value' (which holds the corresponding values)
dfm <- melt(df, id = c('co
On Fri, Feb 18, 2011 at 5:42 PM, Phil Spector wrote:
> Geoff -
> I think this will get you closer to a solution:
>
Yes, much closer, many thanks.
Geoff.
>
> newdf = reshape(df,varying=names(df)[-c(1,2)],direction='long',
>times=2000:2003,idvar=c('country','food'),v.names='X',
Geoff -
I think this will get you closer to a solution:
newdf = reshape(df,varying=names(df)[-c(1,2)],direction='long',
times=2000:2003,idvar=c('country','food'),v.names='X',
timevar='year')
xyplot(X~year|country*food,data=newdf)
df=data.frame(country=c("A","A","A","B","B","B"),
food=rep(c("Apples","Pears","Bananas"),2),
X2000=c(4,5,6,7,6,8),
X2001=c(4,5,6,7,6,8),
X2002=c(4,5,6,7,6,8),
X2003=c(4,5,6,7,6,8));
I have data in the above form trying to get a plot of each fruit over time
year conditioned on c
5 matches
Mail list logo