Re: [R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread arun
With >1 ID_CASE, you may try: xN <- x xN$ID_CASE <- "CB27A" #creating another ID_CASE, other data same x <- rbind(x, xN) res1 <- do.call(rbind, lapply(split(x, x$ID_CASE), function(.x) {     indx <- with(.x, t(sapply(min(MTH_SUPPORT):(max(MTH_SUPPORT) - 2), function(y) c(y,     y + 2  

Re: [R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread arun
For the example, you gave: x ##dataset indx <- t(sapply(min(x$MTH_SUPPORT):(max(x$MTH_SUPPORT) - 2), function(x) c(x, x +     2))) res <- do.call(rbind, apply(indx, 1, function(.indx) {     x1 <- x[x$MTH_SUPPORT >= .indx[1] & x$MTH_SUPPORT <= .indx[2], ]     Period <- paste(.indx[1], .indx[2],

Re: [R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread Abhinaba Roy
ard to a solution to the problem. Thank you Regards On Wed, Jul 30, 2014 at 7:31 PM, PIKAL Petr wrote: > Hi > > Maybe > > ?aggregate > > Use dput for data presentation and no HTML as everything gets scrambled > with it. > > Regards > Petr > > &

Re: [R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread PIKAL Petr
2:46 PM > To: r-help > Subject: [R] DATA SUMMARIZING and REPORTING > > Hi R-helpers, > > I have dataframe like > > ID_CASE YEAR_MTH ATT_1 A1 A2 > A3 CB26A 201302 1 146 42 74 CB26A 201302 0 140 50 77 CB26A 201303 0 > 128 > 36

Re: [R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread Bert Gunter
Is this homework? There is a no homework policy here. And stop posting in HTML --- plain text only-- and learn to use ?dput to post example data. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certa

[R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread Abhinaba Roy
Hi R-helpers, I have dataframe like ID_CASE YEAR_MTH ATT_1 A1 A2 A3 CB26A 201302 1 146 42 74 CB26A 201302 0 140 50 77 CB26A 201303 0 128 36 77 CB26A 201304 1 146 36 72 CB26A 201305 1 134 36 80 CB26A 201305 0 148 30 80 CB26A 201306 0 134 20 72 CB26A