[R] Carrying a value down a data.frame conditionally

2014-12-23 Thread Pooya Lalehzari
Hello, I have a data.frame (below) containing the two fields of Value and Signal and I would need to create the third field of To_Be_Produced. The condition for producing the third field is to carry the 1 in the Signal field down until Value is below 40. Do I have to create a for-loop to do

[R] Conditional Data Manipulation -Cumulative Product

2014-10-07 Thread Pooya Lalehzari
Hello, I have three datasets StartSignals, MainData, StopSignals and need to compound the data for each variable in MainData over dates that fall between the Start and Stop signals. (Stop signals are common and the same to all X1:X5 variables). Please see sample below: The one way I was

Re: [R] Conditional Data Manipulation -Cumulative Product

2014-10-07 Thread Pooya Lalehzari
I noticed the data samples did not come out legible in the original email. Here is the original email with data as plain text that should make it more legible. Hello, I have three datasets StartSignals, MainData, StopSignals and need to compound the data for each variable

Re: [R] Conditional Data Manipulation -Cumulative Product

2014-10-07 Thread Pooya Lalehzari
To: Pooya Lalehzari Cc: R help Subject: RE: [R] Conditional Data Manipulation -Cumulative Product More clear to read, but this is much easier to load into R. Then adding StartSignals$Date - as.Date(StartSignals$Date, %m/%d/%Y) MainData$Date - as.Date(MainData$Date, %m/%d/%Y) StopSignals$Date

Re: [R] Conditional Data Manipulation -Cumulative Product

2014-10-07 Thread Pooya Lalehzari
0.26 0.34 0.34 0.97 1.13 David C -Original Message- From: Pooya Lalehzari [mailto:plalehz...@platinumlp.com] Sent: Tuesday, October 7, 2014 8:06 PM To: David L Carlson Subject: RE: [R] Conditional Data Manipulation -Cumulative Product Hi David, I also made a dput

[R] apply switch to a table

2014-06-17 Thread Pooya Lalehzari
Hello, I have a simple Data table like below: Data V1 V2 1 1 3 2 5 4 And I like to apply a switch to all the values of the table. Exp for one value: switch(as.character(Data[2,1]), 1=One, 2=Two, 3=Three, 4=Four, 5=Five ) What would be the best way to do

[R] Column Name Matching in xts Objects

2013-11-14 Thread Pooya Lalehzari
Hello, I noticed an unexpected behavior when using the xts object and I was wondering if anyone knows why that happens. I have a code to create a new column and copy one of the columns to the new column (please see below): library(xts) df = data.frame(stringsAsFactors=FALSE) df[1:3,date] =

[R] How can I create a data_table with 1000 variables (Var1:Var1000)

2013-08-15 Thread Pooya Lalehzari
Hello everyone, How can I create a data_table with 1000 variables (Var1:Var1000)? Thank you, Pooya Lalehzari THIS E-MAIL IS FOR THE SOLE USE OF THE INTENDED RECIPIENT(S) AND MAY CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION.ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION

Re: [R] How can I create a data.table with 1000 variables (Var1:Var1000)

2013-08-15 Thread Pooya Lalehzari
Sorry. data.table or even data.frame (as they are related). My question is, if there is a short form to refer to all 1000 of them similar to what exists in SAS. Thank you, Pooya Lalehzari. -Original Message- From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Thursday, August 15

Re: [R] How can I create a data.table with 1000 variables (Var1:Var1000)

2013-08-15 Thread Pooya Lalehzari
- From: arun [mailto:smartpink...@yahoo.com] Sent: Thursday, August 15, 2013 5:04 PM To: Pooya Lalehzari Subject: Re: [R] How can I create a data.table with 1000 variables (Var1:Var1000) This question is still not clear.  Could you show a reproducible example as to what you want?  In the title

Re: [R] How can I create a data.table with 1000 variables (Var1:Var1000)

2013-08-15 Thread Pooya Lalehzari
That is great! Thank you so much. -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Thursday, August 15, 2013 5:29 PM To: Ista Zahn Cc: Pooya Lalehzari; R help Subject: Re: [R] How can I create a data.table with 1000 variables (Var1:Var1000) Just to add: You could

[R] xts zoo cannot remove prior installation of package

2013-07-08 Thread Pooya Lalehzari
Hello, Some how, my xts/zoo package ran into trouble. I tried to re-install the packages, I get an error that it cannot remove the prior installation. I uninstalled R and the deleted all the libraries and reinstalled everything fresh. It still complains the same thing. I try to

Re: [R] xts zoo cannot remove prior installation of package

2013-07-08 Thread Pooya Lalehzari
removed everything. Thanks again, Pooya. -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Monday, July 08, 2013 4:26 PM To: Pooya Lalehzari Cc: r-help@r-project.org Subject: Re: [R] xts zoo cannot remove prior installation of package On Jul 8, 2013, at 10:21 AM

[R] set.seed(x)

2013-06-13 Thread Pooya Lalehzari
Hello, If I use set.seed(x) to set a seed for the random number generator, how can I undo that to revert a random output every time I run my code? Thanks, Pooya. THIS E-MAIL IS FOR THE SOLE USE OF THE INTENDED RECIPIENT(S) AND MAY CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION. ANY

[R] Question with apply

2013-05-09 Thread Pooya Lalehzari
Hello, When I use apply on a data frame, it seems like I get an error when I have a column that is not numeric. Via trial and error I realized that if I remove that column, I can get it to run. Is there a better way to tell the function not to worry about the character columns, especially since