Re: [R] Obtaining data from a different row of data frame

2013-09-22 Thread arun
w(df2)[,j], j]   }  }) #   user  system elapsed  #  8.508   0.000   8.523  colN_OF<- ncol(df3[,grep("OF",colnames(df3))]) system.time({  indx1<- unlist(df3[,grep("OF",colnames(df3))],use.names=FALSE)  indx1[rep(seq(nrow(df3)),colN_OF) %in% 1995:2000][indx1[rep(seq(nrow(d

Re: [R] Obtaining data from a different row of data frame

2013-09-21 Thread arun
- val1[indx1+seq_along(indx1)]   colnames(df3)[602:901]<- colnames(df2)[602:901]  }) #  user  system elapsed #  0.568   0.000   0.569  identical(df2,df3) #[1] TRUE A.K. - Original Message - From: arun To: Ira Sharenow Cc: Sent: Sunday, September 22, 2013 1:28 AM Subject: Re:

Re: [R] Obtaining data from a different row of data frame

2013-09-21 Thread arun
d your approach. Ira On 9/21/2013 8:30 PM, arun wrote: Hi Ira, This info was not provided before.  In fact, I wanted to ask about this in cases where the last row entries are not 0.  So, you wanted the newPrices to be NA's for the corresponding rows, right?? Fro

Re: [R] Obtaining data from a different row of data frame

2013-09-21 Thread arun
ot;,colnames(df3))],use.names=FALSE)  df3[,602:901]<- val1[indx1+seq_along(indx1)]  colnames(df3)[602:901]<- colnames(df2)[602:901] }) #  user  system elapsed #  0.600   0.016   0.616 identical(df2,df3) #[1] TRUE A.K. ________________ From: Ira Sharenow To: arun Sent:

Re: [R] Obtaining data from a different row of data frame

2013-09-21 Thread arun
be confusing as: with(df1,P1+OF1) # [1] 13 14 16 18 16 17 18 18 19 19  with(df1,P2+OF2) # [1] 105 104 106 105 105 107 108 108 109 109 which is the same as:  df1$newPrice1 # [1] 13 14 16 18 16 17 18 18 19 19  df1$newPrice2 # [1] 105 104 106 105 105 107 108 108 109 109 - Original Message - From:

Re: [R] Obtaining data from a different row of data frame

2013-09-21 Thread William Dunlap
tfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Ira Sharenow > Sent: Saturday, September 21, 2013 8:31 AM > To: r-help@r-project.org > Subject: [R] Obtaining data

[R] Obtaining data from a different row of data frame

2013-09-21 Thread Ira Sharenow
I have a large data frame with 2,000 rows and 600 columns. I can write loops to solve a smaller problem, but I need a better strategy for this data frame. Below is a simple example with just two stocks. In the data frame, each row represents a trading day. The first column is dates. The next g