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
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
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
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
> 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
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
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
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
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:
>
>
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",
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
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),
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)
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
14 matches
Mail list logo