Re: [R] Reshape question

2012-03-06 Thread David Winsemius
On Mar 6, 2012, at 3:00 PM, David Perlman wrote: I have a data frame in wide format. There are six variables that represent two factors in long format 3x2, Valence and Temperature: head(dpts) File Subj Time Group PainNeg.hot PainNeg.warm SociNeg.hot SociNeg.warm Positiv.hot

[R] Reshape question

2012-03-06 Thread David Perlman
I have a data frame in wide format. There are six variables that represent two factors in long format 3x2, Valence and Temperature: > head(dpts) File Subj Time Group PainNeg.hot PainNeg.warm SociNeg.hot SociNeg.warm Positiv.hot Positiv.warm Errors 1 WB101_1_1_dp.txt 1011 MN

Re: [R] reshape question

2009-11-25 Thread AC Del Re
Thanks for your help on this Hadley and David! Dennis Murphy also had a good solution (changing list(data.out2[-1])...etc to names(data.out2[-1]}...): > data.out3 <- reshape(data.out2, direction = 'long', varying = names(data.out2[-1]), + idvar = 'id') > data.out4 <- split(data.out3, da

Re: [R] reshape question

2009-11-24 Thread Joe King
Behalf Of David Winsemius Sent: Tuesday, November 24, 2009 6:43 PM To: AC Del Re Cc: r-help@r-project.org Subject: Re: [R] reshape question On Nov 24, 2009, at 8:33 PM, AC Del Re wrote: > Hi All, > > I am wanting to convert a data.frame from a wide format to a long > format > (wit

Re: [R] reshape question

2009-11-24 Thread hadley wickham
> I don't really understand what you want and the example solution throws away > quite a lot of data, so consider this alternative: > > data.out2 <- read.table(textConnection("id   rater.1 n.1   rater.2 n.2 > rater.3 n.3   rater.4 n.4 > 11   11 0.118  79        NA  NA        NA  NA        NA  N

Re: [R] reshape question

2009-11-24 Thread David Winsemius
On Nov 24, 2009, at 8:33 PM, AC Del Re wrote: Hi All, I am wanting to convert a data.frame from a wide format to a long format (with >1 variable) and am having difficulties. Any help is appreciated! #current wide format head(data.out2) id rater.1 n.1 rater.2 n.2 rater.3 n.3

[R] reshape question

2009-11-24 Thread AC Del Re
Hi All, I am wanting to convert a data.frame from a wide format to a long format (with >1 variable) and am having difficulties. Any help is appreciated! #current wide format > head(data.out2) id rater.1 n.1 rater.2 n.2 rater.3 n.3 rater.4 n.4 11 11 0.118 79NA NA

Re: [R] Reshape question.

2009-03-11 Thread rkevinburton
Thank you for you reply. I will try this. The inital few rows in the .dat file look like: Year,DayOfYear,Sku,Quantity,CatId,Category,SubCategory 2009,1,100051,1,10113,"MEN","Historical men's" 2009,1,100130,1,10638,"ACCESSORIES & MAKEUP","ALL Kids Accessories" 2009,1,100916,1,10222,"WOMEN","TV & M

Re: [R] Reshape question.

2009-03-11 Thread Tal Galili
how about: c2009 <- cast(m2009, Category + SubCategory +DayOfYear ~ variable , sum) ? p.s: toy data would be nice to have :) On Wed, Mar 11, 2009 at 9:47 PM, wrote: > This hopefully is trivial. I am trying to reshape the data using the > reshape package. > > First I read in the data: > >

[R] Reshape question.

2009-03-11 Thread rkevinburton
This hopefully is trivial. I am trying to reshape the data using the reshape package. First I read in the data: a2009 <- read.csv("Total2009.dat", header = TRUE) Then I trim it so that it only contains the columns that I have interested in: m2009 <- melt(a2009, id.var=c("DayOfYear","Category",

Re: [R] reshape question

2008-11-18 Thread Alexandre Swarowsky
solution: reshape package, melt function. On Tue, 2008-11-18 at 02:07 +, Alexandre Swarowsky wrote: > Hi, > > It's probably a simple issue but I'm struggling with that. I'll use the > example shown in the help page. > > head(Indometh) > wide <- reshape(Indometh, v.names="conc", idvar="Subje

[R] reshape question

2008-11-17 Thread Alexandre Swarowsky
Hi, It's probably a simple issue but I'm struggling with that. I'll use the example shown in the help page. head(Indometh) wide <- reshape(Indometh, v.names="conc", idvar="Subject", timevar="time", direction="wide") head(wide) reshape(wide, idvar="Subject", varying=list(2:12),

Re: [R] reshape question

2008-02-08 Thread Chuck Cleland
On 2/8/2008 9:15 AM, Ista Zahn wrote: > I know there are a lot of reshape questions on the mailing list, but I > haven't been able to find an answer to this particular issue. > > I am trying to get a datafame structured like this: > > > sub <- rep(1:5) > > ta1 <- rep(1,5) > > ta2 <- rep(2,5)

[R] reshape question

2008-02-08 Thread Ista Zahn
I know there are a lot of reshape questions on the mailing list, but I haven't been able to find an answer to this particular issue. I am trying to get a datafame structured like this: > sub <- rep(1:5) > ta1 <- rep(1,5) > ta2 <- rep(2,5) > tb1<- rep(3,5) > tb2 <- rep(4,5) > DF <- data.fr