Re: [R] pivot table

2014-02-28 Thread jim holtman
Is this what you want: > x id agency offer month product 1 1 a L genstar 2 2 b M feb meteor 3 3 c N genmoon 4 4 d O marchmoon > require(reshape2) > dcast(x, agency + offer ~ product, fun = length) Using product as value column: use value

[R] pivot table

2014-02-28 Thread lara.palandra
hi..i would create a pivot table in R and i would create two levels of columns. I'll try to explain better. I have a table so done: id agency offer month product 1 aL gen star 2 bM feb meteor 3

Re: [R] additions to r pivot table

2014-02-26 Thread arun
Hi Burnette, Try: indx <- grep("\\bMW\\b|\\bOT\\b|\\bposter\\b|\\brecords\\b", rownames(res3)) indx1 <- grep("Grand Total",rownames(res3)) res3R <-  as.data.frame(matrix(NA,ncol=ncol(res3),nrow=nrow(res3),dimnames= list(rownames(res3),c("rate of Count of Case ID", "rate of Sum of BW_Due", "ra

Re: [R] count and sum simultaneously in R pivot table

2014-02-18 Thread Crombie, Burnette N
The script works nicely, Arun. You were right, I pasted code from email instead of Rhelp and didn't reformat properly in R. I appreciate your time with this! -Original Message- It seems like part of the next line is also being run (in the end 'colnames'). For e.g. res2 <- within(as.dat

Re: [R] count and sum simultaneously in R pivot table

2014-02-18 Thread Crombie, Burnette N
r-help@r-project.org Cc: Crombie, Burnette N Subject: Re: [R] count and sum simultaneously in R pivot table Hi, Check if this works: library(reshape2) res1 <- acast(FLSAdata_melt, ViolationDesc + ReasonDesc ~ variable, sum, margins=TRUE)[,-4] res2 <- within(as.data.frame(res1),`Count

Re: [R] count and sum simultaneously in R pivot table

2014-02-17 Thread arun
          measure=c("BW_Due", "BW_ATP", "EEs_Rep")) # # FLSA_Violation_Reason_cast <- cast(FLSA_Violation_Reason_melt, #                                    ViolationDesc + ReasonDesc ~ variable, #                                    sum, margins=TRUE) Thank you. -- View this messa

[R] count and sum simultaneously in R pivot table

2014-02-06 Thread bcrombie
ariable, #sum, margins=TRUE) Thank you. -- View this message in context: http://r.789695.n4.nabble.com/count-and-sum-simultaneously-in-R-pivot-table-tp4684896.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] pivot table

2012-11-07 Thread farnoosh sheikhi
I'm using Revolution R Enterprise. This command worked perfectly. Thank you so much for your help and time:-)   Best,Farnoosh Sheikhi Cc: R help Sent: Wednesday, November 7, 2012 10:47 AM Subject: Re: [R] pivot table HI, Could you tell me which version

Re: [R] pivot table

2012-11-07 Thread farnoosh sheikhi
_ Cc: R help Sent: Tuesday, November 6, 2012 5:50 PM Subject: Re: [R] pivot table Hi, May be this helps: dat1<-read.table(text=" ID Lab   Status a 1  N a       1  A a       2  N b       3       N b       1  A ",sep="

Re: [R] pivot table

2012-11-07 Thread arun
    1  1  0 #2  b  1  0  0  1 A.K. From: farnoosh sheikhi To: arun Cc: R help Sent: Wednesday, November 7, 2012 1:40 PM Subject: Re: [R] pivot table Hi there, Thanks forhelping. I really appreciate it. The only thing is I get this e

Re: [R] pivot table

2012-11-06 Thread farnoosh sheikhi
It worked beautifully. Thank you so much:-)   Best,Farnoosh Sheikhi Cc: R help Sent: Tuesday, November 6, 2012 2:44 PM Subject: Re: [R] pivot table Hi, Is this okay? library(reshape2) dat1<-read.table(text=" ID   Diag   Proc  DOB  Gender   a 

Re: [R] pivot table

2012-11-06 Thread farnoosh sheikhi
Hi there, Thanks a lot for your help, but Proc doesn't show in the result. I also want to assign 1 and 0 instead of the name of variables. Thanks a lot.   Best,Farnoosh Sheikhi Cc: R help Sent: Tuesday, November 6, 2012 1:42 PM Subject: Re: [R] pivot

Re: [R] pivot table

2012-11-06 Thread farnoosh sheikhi
   Lab3.A a           11       1000 b    0    1001               0 Thanks a lot:) Best,Farnoosh Sheikhi Cc: R help Sent: Tuesday, November 6, 2012 2:44 PM Subject: Re: [R] pivot table Hi, Is this okay? library(reshape2) dat1<-read.table(text=" ID   Dia

Re: [R] pivot table

2012-11-06 Thread arun
__ From: farnoosh sheikhi To: arun Cc: R help Sent: Tuesday, November 6, 2012 7:31 PM Subject: Re: [R] pivot table Hi again, I have another question for different data. Here is how my data looks like: ID     Lab   Status a         1          N a   1          A a   2  

Re: [R] pivot table

2012-11-06 Thread arun
__ From: farnoosh sheikhi To: arun Cc: R help Sent: Tuesday, November 6, 2012 5:12 PM Subject: Re: [R] pivot table Hi there, Thanks a lot for your help, but Proc doesn't show in the result. I also want to assign 1 and 0 instea

Re: [R] pivot table

2012-11-06 Thread arun
DOB Gender Diag.1 Diag.2 Diag.3 Diag.4 Diag.5 #1  a 10/15/1969  M  diag1     diag3      #2  b  8/25/1978  F     diag2     diag4  diag4 #3  c  1/10/1985  M  diag1              A.K. - Original Message - From: farnoosh sheikhi To: "r-help@R-project.org" Cc: Sent: Tu

[R] pivot table

2012-11-06 Thread farnoosh sheikhi
Hello, I have a data which looks like below: Some of the patients have multiple diagnosis. ID(200 patients)   Diag (100 unique Diag-200 in general)   Proc (50 uniqe Proc)  DOB (200)   Gender (200)    a                           daig1 b                           diag2 c                          

Re: [R] Pivot Table "like" structure

2012-10-16 Thread David Winsemius
On Oct 13, 2012, at 5:38 PM, Bhupendrasinh Thakre wrote: HI Team, I am currently working on problem and stumped on "for" loop. Data: structure(list(Coutry = structure(c(3L, 3L, 3L, 3L, 2L, 2L, 1L, 1L), .Label = c("J", "M", "U"), class = "factor"), State = structure(c(1L, 1L, 4L, 2L, 5L, 5

Re: [R] Pivot Table "like" structure

2012-10-16 Thread John Kane
quot;ABCD", "EFGH", "FGHJ", ""), class = "factor"), Char3 = structure(c(1L, 1L, 2L, 3L, 1L, 1L, 2L, 3L), .Label = c("ASDFG", "D", "EE"), class = "factor")), .Names = c("Coutry", "St

Re: [R] Pivot Table "like" structure

2012-10-13 Thread arun
EFGH EE 1  1    1 A.K. - Original Message - From: Bhupendrasinh Thakre To: "r-help@r-project.org help" Cc: Sent: Saturday, October 13, 2012 8:38 PM Subject: [R] Pivot Table "like" structure HI Team, I am currently working on problem and stumped on "

[R] Pivot Table "like" structure

2012-10-13 Thread Bhupendrasinh Thakre
HI Team, I am currently working on problem and stumped on "for" loop. Data: structure(list(Coutry = structure(c(3L, 3L, 3L, 3L, 2L, 2L, 1L, 1L), .Label = c("J", "M", "U"), class = "factor"), State = structure(c(1L, 1L, 4L, 2L, 5L, 5L, 3L, 6L), .Label = c("A", "C", "K", "O", "S", "T"), class =

Re: [R] pivot table help

2011-12-04 Thread set
Thank you very much! works perfectly! -- View this message in context: http://r.789695.n4.nabble.com/pivot-table-help-tp4155144p4156393.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.eth

Re: [R] pivot table help

2011-12-03 Thread jim holtman
Forgot, you can also do this: > dcast(x.m, Cluster ~ value, fun = length) Cluster ind1 ind2 ind3 1 1110 2 2101 3 3110 > On Sat, Dec 3, 2011 at 7:02 PM, jim holtman wrote: > try this: > >> x <- read.table(text = "Cluster   Member1    Member

Re: [R] pivot table help

2011-12-03 Thread jim holtman
try this: > x <- read.table(text = "Cluster Member1Member2 + 1ind1 ind2 + 2ind3 ind1 + 3ind2 ind1", as.is = TRUE, header = TRUE) > require(reshape2) > x.m <- melt(x, id = "Cluster") > x.m Cluster variable value 1 1 Me

Re: [R] pivot table help

2011-12-03 Thread Richard M. Heiberger
Pivot tables are an Excel concept, not an R concept. That means you must give an example of your starting pivot table as an R object (use dump() so we can pick it up from the email and execute it immediately). and an example of the R object you want as the result. Use a trivial but complete exampl

[R] pivot table help

2011-12-03 Thread set
Hello R-users, I've got a huge table with about 20.00 rows and 50 columns. The table now has headers as Members1, Members2 etc. My data are 8 different individuals. And I've got a column with clusters. So each individual belongs to different clusters and can occurs multiple times within a cluster

Re: [R] pivot table in R

2008-01-29 Thread Christos Hatzis
AM > To: [EMAIL PROTECTED]; r-help@r-project.org > Subject: Re: [R] pivot table in R > > A = read.table("clipboard", header=TRUE) > > A > sex age region no_of_accidents > 1 F young north 10 > 2 F young south 12 > 3 F ol

Re: [R] pivot table in R

2008-01-29 Thread John Kane
Have a look at the reshape package. With your data as data.frame xx : library(reshape) dd <- melt(xx, id=c("sex", "age", "region"),measured=c(no_of_accidents)); dd cast(dd, sex~variable, sum) --- [EMAIL PROTECTED] wrote: > Hello, > > I'm struggling with an elementary problem with R. I > have

Re: [R] pivot table in R

2008-01-29 Thread hadley wickham
> I'm struggling with an elementary problem with R. I have a simple data > frame such as this one giving the number of accidents subdivided by sex, > age and region. If you're trying to do pivot tables in R, I'd recommend looking at the reshape package, which was designed specifically to tackle th

Re: [R] pivot table in R

2008-01-29 Thread David Winsemius
[EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED] k: Three or four solutions have already been offered. Here is (yet) another: > Atxt <- " + sex age region no_of_accidents + 1 F young north 10 + 2 F young south 12 + 3 F old north 5 + 4 F

Re: [R] pivot table in R

2008-01-29 Thread Attiglah, Mama
MAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 29 January 2008 12:05 To: r-help@r-project.org Subject: [R] pivot table in R Hello, I'm struggling with an elementary problem with R. I have a simple data frame such as this one giving the number of accidents

Re: [R] pivot table in R

2008-01-29 Thread Romain Francois
Hi Pietro, Depending on the actual structure you want in the output, you can use some of the functions in the apply family, particularly tapply, aggregate, or by. Something like : R> tapply( d[["no_of_accidents" ]], d[[ "sex" ]], sum ) F M 34 83 R> aggregate( d["no_of_accidents" ], d[ "sex" ],

[R] pivot table in R

2008-01-29 Thread pietro . parodi
Hello, I'm struggling with an elementary problem with R. I have a simple data frame such as this one giving the number of accidents subdivided by sex, age and region. sex age region no_of_accidents F young north 10 F young south 12 F o