Re: [R] cor() btwn columns in two matrices - no complete element pairs

2008-08-15 Thread rcoder
is satisfied, but the data rows do not overlap at all. rcoder wrote: Hi everyone, I'm trying to calculate correlation coefficients between corresponding columns in two matrices with identical dimensions but different data. The problem is that the matrices contain NAs in different locations

[R] cor() btwn columns in two matrices - no complete element pairs

2008-08-15 Thread rcoder
Is there something I'm not including in the 'cor' parentheses? I apologise for not including the true original data frames. Thanks, rcoder -- View this message in context: http://www.nabble.com/cor%28%29-btwn-columns-in-two-matrices---no-complete-element-pairs-tp18998875p18998875.html Sent from the R help

[R] merging data sets to match data to date

2008-08-13 Thread rcoder
, but the operation did not fill the results matrix. Coulc anyone offer any advice to assist with this operation? Thanks, rcoder -- View this message in context: http://www.nabble.com/merging-data-sets-to-match-data-to-date-tp18962197p18962197.html Sent from the R help mailing list archive

[R] conditional IF with AND

2008-08-13 Thread rcoder
of the syntax for incorporating an AND in a conditional IF statement. Thanks, rcoder -- View this message in context: http://www.nabble.com/conditional-IF-with-AND-tp18966890p18966890.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r

Re: [R] merging data sets to match data to date

2008-08-13 Thread rcoder
Dear Henrique, This is exactly what I need. Thank you very much for your help! rcoder Henrique Dallazuanna wrote: Try this: x - data.frame(Dates = seq(as.Date('2008-01-01'), as.Date('2008-01-31'), by = 'days'), Values

Re: [R] conditional IF with AND

2008-08-13 Thread rcoder
Thank you all for your replies. This is all very useful information for me! Ted, thank you very much for the extra explanation and example. Many thanks, rcoder Ted.Harding-2 wrote: On 13-Aug-08 16:45:27, rcoder wrote: Hi everyone, I'm trying to create an if conditional statement

Re: [R] ignoring zeros or converting to NA

2008-08-13 Thread rcoder
is generated: Error in if mat[j,k] !=0 { :missing value where TRUE/FALSE needed I'm not sure how to resolve this. Thanks, rcoder Henrik Bengtsson (max 7Mb) wrote: FYI, there is an isZero() in the R.utils package that allows you to specify the precision. It looks like this: isZero

[R] missing TRUE/FALSE error in conditional construct

2008-08-13 Thread rcoder
) { for (k in 1:2000) { if(mat[j,k]!=0 !is.NaN(mat[j,k])) {mat_zeroless[j,k]-mat[j,k]} } } ##Code End Error in if (mat[j,k] !=0 !is.NaN(mat[j,k])) { :missing value where TRUE/FALSE needed I'm not sure how to resolve this. rcoder -- View this message in context: http

[R] ignoring zeros or converting to NA

2008-08-12 Thread rcoder
to an !all(is.na() construct)? Thanks, rcoder -- View this message in context: http://www.nabble.com/ignoring-zeros-or-converting-to-NA-tp18948979p18948979.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing

[R] increment size in for loop

2008-08-08 Thread rcoder
Hi everyone, Is there a way to vary the increment size in a for loop? For e.g. when incrementing in steps greater than unity. Thanks, rcoder -- View this message in context: http://www.nabble.com/increment-size-in-for-loop-tp18893893p18893893.html Sent from the R help mailing list archive

Re: [R] increment size in for loop

2008-08-08 Thread rcoder
Don't worry, I got it: for(x in seq(1,100,5)) { print(x) } where the step size is 5. rcoder rcoder wrote: Hi everyone, Is there a way to vary the increment size in a for loop? For e.g. when incrementing in steps greater than unity. Thanks, rcoder -- View

Re: [R] using acf() for multiple columns

2008-08-07 Thread rcoder
Hi Gary, Thanks for your reply. This works fine. Is there any way to send the ACF data to a matrix, so I could analyse the data in excel for e.g.? Thanks, rcoder Ling, Gary (Electronic Trading) wrote: Hi, here is one possible solution ... -gary ### example ### # create

[R] long run time for loop operation matrix fill

2008-08-07 Thread rcoder
there is nothing wrong with the code. I was just wondering if this is normal program execution speed for such an operation on a P4 with 2GB RAM? Thanks, rcoder -- View this message in context: http://www.nabble.com/long-run-time-for-loop-operation---matrix-fill-tp18876372p18876372.html Sent from

[R] using acf() for multiple columns

2008-08-06 Thread rcoder
the acf was calculated between adjacent columns in the matrix, which is something I was puzzled about. Thanks, rcoder -- View this message in context: http://www.nabble.com/using-acf%28%29-for-multiple-columns-tp18858672p18858672.html Sent from the R help mailing list archive at Nabble.com

Re: [R] problem with nested loop for regression

2008-08-05 Thread rcoder
),k) in the regression statement - forcing successive slope data to overwrite cell locations containing intercept data. Also, the full code takes an awfully long time to run. Would anyone be able to suggest a way for mee to speed it up - perhaps in the regression algorithm? Thanks, rcoder

Re: [R] problem with nested loop for regression

2008-08-04 Thread rcoder
Hi, I guess my question is really more about the nested for loop construct and whether it is doing what I intend it to do in my code in the previous post. I would be grateful if anyone who has used nested loops could let me know if I am doing something wrong. Thanks, rcoder rcoder wrote

[R] problem with nested loop for regression

2008-08-03 Thread rcoder
,]-Pmult[j,]*mult_col[j,] } #rolling regression analysis... for (k in 1:maxcol) #2nd nested loop { sel_col-PmatWt[,k] if(!all(is.na(sel_col))) {Preg[,k]-coef(lm(tt~sel_col))} } } #Code End Thanks, rcoder -- View this message

Re: [R] losing row.names in matrix operations

2008-08-03 Thread rcoder
Thanks for your reply Gabor. As I already have a dates column in my dataframe (in column row.names), is it possible to preserve this whilst still making a data set suitable for rollapply()? Thanks, rcoder Gabor Grothendieck wrote: If its regular you can convert it to ts or zoo. If its

[R] losing row.names in matrix operations

2008-08-02 Thread rcoder
matrix, I lose the dates in the row.names column. I just want to know if anyone could suggest a way to get around this problem, i.e. keep the row.names column in place, and use the rollapply() statement as above. Thanks, rcoder -- View this message in context: http://www.nabble.com/losing

Re: [R] Re gression between adjacent columns - error with NAs

2008-07-31 Thread rcoder
and examples. Any suggestions would be grately appreciated. Many thanks, rcoder Gabor Grothendieck wrote: That's good. Try this: 1. put set.seed(1) at the top of the code to make it reproducible. 2. replace body of loop with: sel_col-SourceMat[, i] out - try(coef(lm(tt~sel_col

[R] rollapply() to portions of a matrix

2008-07-31 Thread rcoder
in the parentheses? One way would be to introduce an if statement, but is this the only way? Thanks, rcoder -- View this message in context: http://www.nabble.com/rollapply%28%29-to-portions-of-a-matrix-tp18761906p18761906.html Sent from the R help mailing list archive at Nabble.com

[R] Re gression between columns in matrix - with some/full NAs

2008-07-30 Thread rcoder
in the matrix in turn SourceMat[,i]-coef(lm(tt~sel_col), na.action=NULL) } Thanks, rcoder rcoder wrote: Hi everyone, I'm having trouble applying the Cor() function to two matrices, both of which contain NAs. I am doing the following: a-cor(m1, m2, use

Re: [R] rolling regression between adjacent columns

2008-07-30 Thread rcoder
in the matrix in turn SourceMat[,i]-coef(lm(tt~sel_col), na.action=NULL) } Thanks, rcoder Gabor Grothendieck wrote: Read the last line of every message to r-help. On Tue, Jul 29, 2008 at 6:15 PM, rcoder [EMAIL PROTECTED] wrote: Hi everyone, I am trying to apply linear

[R] Re gression between adjacent columns - error with NAs

2008-07-30 Thread rcoder
) { sel_col-SourceMat[col(SourceMat)==i] #selecting the correct column in the matrix in turn ResultMat[,i]-coef(lm(tt~sel_col, na.action=NULL)) } ##Code end I would be grateful for any suggestions to avoid this problem. Thanks, rcoder rcoder wrote

[R] correlation between matrices - both with some NAs

2008-07-29 Thread rcoder
know how I can apply a correlation, ignoring any NAs? Thanks, rcoder -- View this message in context: http://www.nabble.com/correlation-between-matrices---both-with-some-NAs-tp18721853p18721853.html Sent from the R help mailing list archive at Nabble.com

Re: [R] rollapply() opertation on time series

2008-07-29 Thread rcoder
Hi Gabor, Thanks for your reply. Assuming I have a time series that is ready made (i.e. not constructed it using a zoo function) will the procedure below still retain the dates in the matrix? Thanks, rcoder quote author=Gabor Grothendieck rollapply along an index: library(zoo) z - zoo(matrix

[R] rolling regression between adjacent columns

2008-07-29 Thread rcoder
rollapply(), the columns are not recognised and the regression breaks down. Is there a more robust way to reference the columns I need, so that I can apply the regression across the matrix; 'by.column', but every other column? Thanks, rcoder -- View this message in context: http://www.nabble.com

[R] rollapply() opertation on ts matrix

2008-07-28 Thread rcoder
Hi everyone, Is there a way to perform a rollapply operation on a time series data matrix and preserve the time frame? Currently, when I apply rollapply in its standart form, the date column is no longer present in the o/p matrix. Thanks, rcoder -- View this message in context: http

[R] rollapply() opertation on time series

2008-07-28 Thread rcoder
rcoder wrote: Hi everyone, Is there a way to perform a rollapply operation on a time series data matrix and preserve the time frame? Currently, when I apply rollapply in its standart form, the date column is no longer present in the o/p matrix. Thanks, rcoder -- View

[R] product of successive rows

2008-07-27 Thread rcoder
Hi everyone, I want to perform an operation on a matrx that outputs the product of successive pairs of rows. For example: calculating the product between rows 1 2; 3 4; 5 6...etc. Does anyone know of any readily available functions that can do this? Thanks, rcoder -- View this message

[R] Rolling regression - o/p selected coefficients

2008-07-27 Thread rcoder
Hi everyone, Using the rolling regression function - rollingRegression(formula, data, width, ...) - is there a way to output only selected coefficients to a results matrix. For e.g. if I only wanted the slope coefficients to be recorded, how would I go about doing this? Thanks, Michael --

Re: [R] Rolling range and regression calculations

2008-07-25 Thread rcoder
of sequential rows in a preceeding matrix: i.e. rows 1*2 - row 1 in o/p matrix; rows2*3- row 2; rows 4*5-row3 etc. Thanks, rcoder stephen sefick wrote: how about rollapply in the zoo package? On Fri, Jul 25, 2008 at 8:37 AM, rcoder [EMAIL PROTECTED] wrote: Hi Achim, Thanks for your

[R] Rolling range and regression calculations

2008-07-24 Thread rcoder
to a separate matrix. On a separate matter, I have a matrix containing data on which perform a regresssion over a rolling time period. Is there a convenient way I can do this for each column, and then save the gradient to an o/p matrix? Thanks, rcoder -- View this message in context: http

Re: [R] Mapping data onto score

2008-07-16 Thread rcoder
be grateful for any suggestions on this slight modification. Otherwise, I can make do with my version. Thanks, rcoder rcoder wrote: Thank you Ben! This is very clear. rcoder Ben Tupper wrote: On Jul 15, 2008, at 5:16 PM, rcoder wrote: Hi Ben, Yes, this is more or less what I

Re: [R] Mapping data onto score

2008-07-16 Thread rcoder
ranges for data matrix mm[,n]-range(mat[,n],na.rm=T) #inserts min/max values into sc matrix for (m in 1:nr) { sc[m,n]-100*(mat[m,n]-mm[1,n])/(mm[2,n]-mm[1,n]) #re-scaling onto percentile ranking } } rcoder rcoder

[R] Mapping data onto 1-10 score

2008-07-15 Thread rcoder
Hi everyone, I want to score a set of data (-ve to +ve) using a 0-10 scale. I have the data in an R matrix, so I need to add another column, containing the scores and resave. I would be grateful for suggestions on how best to do this. Thanks, rcoder -- View this message in context: http

[R] Mapping data onto score

2008-07-15 Thread rcoder
Hi everyone, I want to score a set of data (-ve to +ve) using a 0-10 scale. I have the data in an R matrix, so I need to add another column, containing the scores and resave. I would be grateful for suggestions on how best to do this. Thanks, rcoder -- View this message in context: http

Re: [R] Mapping data onto score

2008-07-15 Thread rcoder
, rcoder Ben Tupper wrote: On Jul 15, 2008, at 8:16 AM, rcoder wrote: Hi everyone, I want to score a set of data (-ve to +ve) using a 0-10 scale. I have the data in an R matrix, so I need to add another column, containing the scores and resave. Hi, I am a little fuzzy on what

Re: [R] Mapping data onto score

2008-07-15 Thread rcoder
Thank you Ben! This is very clear. rcoder Ben Tupper wrote: On Jul 15, 2008, at 5:16 PM, rcoder wrote: Hi Ben, Yes, this is more or less what I want to do. I want to apply this data in columns in a matrix, and insert the results to additional columns. I am not entirely aware

Re: [R] shifting data in matrix by n rows

2008-07-11 Thread rcoder
This is great! Thank you very much Gabor. rcoder Gabor Grothendieck wrote: See ?lag and in zoo ?lag.zoo. Both pages have examples. Using lag.zoo here it is with your data: Lines - Date Apples Oranges Pears 1/7 2 35 2/7 1 47 3/7

Re: [R] shifting data in matrix by n rows

2008-07-10 Thread rcoder
, rcoder Gabor Grothendieck wrote: If its a zoo or ts time series you can use the lag function. On Wed, Jul 9, 2008 at 2:57 PM, rcoder [EMAIL PROTECTED] wrote: Hi everyone, I have some data in a matrix, and I want to shift it down by one row. The matrix in question has a date column

[R] shifting data in matrix by n rows

2008-07-09 Thread rcoder
location? Thanks, rcoder -- View this message in context: http://www.nabble.com/shifting-data-in-matrix-by-n-rows-tp18368420p18368420.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch

Re: [R] shifting data in matrix by n rows

2008-07-09 Thread rcoder
code, at least provide a before/after version of the matrix that you would like. It is easy to use indexing to move stuff around, we just have to know what is it that you want to move. On Wed, Jul 9, 2008 at 2:57 PM, rcoder [EMAIL PROTECTED] wrote: Hi everyone, I have some data in a matrix