Re: [R] how to call a C-library in R

2008-08-23 Thread rcoder
Hi Cindy, Take a look at the following. This should help get you started. http://www.stat.umn.edu/~charlie/rc/ rcoder cindy Guo wrote: > > Hi, everyone, > > I need to use a C library. But since I have little experience in C, I want > to call this C library in R and progra

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

2008-08-16 Thread rcoder
Hi Daniel, Thanks for your reply. I experimented with various options since my poet and eventually tried use="pairwise.complete.obs" which seemed to do the trick. Thanks, rcoder Daniel Malter wrote: > > Hi, > > the argument use should be: use="p" (for pai

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

2008-08-15 Thread rcoder
no complete element pairs 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-

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 c

Re: [R] ignoring zeros or converting to NA

2008-08-13 Thread rcoder
ror 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 prec

[R] missing TRUE/FALSE error in conditional construct

2008-08-13 Thread rcoder
eros## for (j in 1:5000) { 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

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 cre

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

[R] conditional IF with AND

2008-08-13 Thread rcoder
le 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

[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 at

[R] ignoring zeros or converting to NA

2008-08-12 Thread rcoder
something similar 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-p

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, >

[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

[R] long run time for loop operation & matrix fill

2008-08-07 Thread rcoder
lieve 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 fro

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 > &

[R] using acf() for multiple columns

2008-08-06 Thread rcoder
, but the titles suggested 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 mail

Re: [R] problem with nested loop for regression

2008-08-05 Thread rcoder
k] vs [j:(j+1),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? Than

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

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

[R] problem with nested loop for regression

2008-08-03 Thread rcoder
t) for (j in 1:5) #1st nested loop { PmatWt[j,]<-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~

[R] rollingRegression() aplied between vector and matrix

2008-08-02 Thread rcoder
offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases Can anyone see what I am doing incorrectly? I hope the example code helps. Thanks, rcoder -- View this message in context: http://www.nabble.com/rollingRegression%28%29-aplied-between-vector-and-matrix-tp18788824p18788

[R] losing row.names in matrix operations

2008-08-02 Thread rcoder
matrix into a time series 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://ww

[R] rollapply() to portions of a matrix

2008-07-31 Thread rcoder
arguments 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

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

2008-07-31 Thread rcoder
help files 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<-S

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

2008-07-30 Thread rcoder
rce matrix: for (i in 1:10) { 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 p

Re: [R] rolling regression between adjacent columns

2008-07-30 Thread rcoder
)==i] #selecting the correct column 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 <

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

2008-07-30 Thread rcoder
urceMat)==i]#selecting the correct column 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 >

[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.

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(

[R] correlation between matrices - both with some NAs

2008-07-29 Thread rcoder
complete element pairs Does anyone 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 mailin

[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,

[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] 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 -- 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 -

Re: [R] Rolling range and regression calculations

2008-07-25 Thread rcoder
oduct 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 PROTECT

Re: [R] Rolling range and regression calculations

2008-07-25 Thread rcoder
Hi Achim, Thanks for your reply. rollmean and rollmax functions exist, but is there anything for returning the minima on a rolling basis? I know there is no rollmin in the zoo library. Thanks, rcoder Achim Zeileis wrote: > > On Thu, 24 Jul 2008, rcoder wrote: > >> Hi ev

[R] Rolling range and regression calculations

2008-07-24 Thread rcoder
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
#now calculate respective 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 }

Re: [R] Mapping data onto score

2008-07-16 Thread rcoder
would 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

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 re

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

[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

[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

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 3

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

2008-07-10 Thread rcoder
e? Thanks, 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

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

2008-07-09 Thread rcoder
you don't have 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: >

[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