Re: [R] loop problem

2009-10-02 Thread David Winsemius
On Oct 2, 2009, at 7:34 AM, crenial30 wrote: Thanks a lot David for your answer. I am sorry for being so minimal. I wanted to produce a list/vector/table consisting each vector produced from this code len<-20 for (n1 in seq(0,(len-1),by=1)){ f <- R_event[R_event > (rx[1]+ n1*300)& R_even

Re: [R] loop problem

2009-10-02 Thread crenial30
Thanks a lot David for your answer. I am sorry for being so minimal. I wanted to produce a list/vector/table consisting each vector produced from this code len<-20 for (n1 in seq(0,(len-1),by=1)){ f <- R_event[R_event > (rx[1]+ n1*300)& R_event <= (rx[1] + 300*(n1+1))] //create list for each va

Re: [R] loop problem

2009-09-29 Thread David Winsemius
That code is way more than a _minimal_ example, and its not _reproducible_ either, so just a comment: Have you considered creating a vector rather than separate "event" variables? R_ev[1:16] <- R_event > (rx[1] + 300*(0:15)& R_event <= (rx[1] + 300*(1:16) ?cut # would also appear to b

Re: [R] loop problem for extract coefficients

2009-04-07 Thread Arien Lam
Hi Alex, On Sun, April 5, 2009 16:49, Alex Roy wrote: > Dear R users, > I have problem with extracting coefficients from a > object. Here, X (predictor)and Y (response) are two matrix , I am > regressing > X ( dimensions 10 x 20) on each of columns of Y[,1] (10 x 1) and want

Re: [R] loop problem for extract coefficients

2009-04-05 Thread Bill.Venables
Perhaps your loop should be more than just a print statement. That works fine! You need to place the print statement after the '{', not before it. fit$coefficients is a 21 x 20 array (the rows are lablelled 0 to 20) and you are trying to put it in the jth *column* of a 20 x 20 matrix. Not sur

Re: [R] loop problem

2009-03-26 Thread Jim Lemon
Muhammad Azam wrote: Dear R members I have a problem regarding storing the lists. Let L=number of distinct values of any predictor (say L=5) P=number of predictors (say P=20) g1 <- c() for(i in 1:P){ if(L > 1){ for(j in 1:(L-1)){ g <- g1[j] <- g } } g2

Re: [R] Loop problem

2008-07-14 Thread Gabor Grothendieck
Try this: pk[rep(1, 4), ] On Mon, Jul 14, 2008 at 4:33 AM, fernanda lopez <[EMAIL PROTECTED]> wrote: > Dear all, > I want to > write ck<-cbind(rep(pk[1,1],4),rep(pk[1,2],4),rep(pk[1,3],4)) state ment > in a loop . How can I write it ? > > > > > >> pk > [,1] [,2]

Re: [R] Loop problem

2008-07-14 Thread Daniel Malter
Hi, do you mean this? pk<-matrix(rnorm(12),nrow=4,ncol=3) ck1<-cbind(rep(pk[,1],4),rep(pk[,2],4),rep(pk[,3],4)) ## or ck2<-cbind(rep(pk[,1],each=4),rep(pk[,2],each=4),rep(pk[,3],each=4)) pk ck1 ck2 best, Daniel fernanda lopez wrote: > > Dear all, > I want to > write ck<-cbi

Re: [R] Loop problem

2008-07-14 Thread Dimitris Rizopoulos
try this: pk <- matrix(rnorm(12), 4, 3) matrix(rep(pk[1, ], each = 4), 4) I hope it helps. Best, Dimitris Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/3370

Re: [R] Loop problem

2008-03-27 Thread Jim Lemon
Oops, missed the first line of the example: storm.data<-data.frame(meas.index=10001:2,cumrain=runif(1,-10,10)+10) You can generalize the function to whatever column names you have like this: find.max.rain<-function(raindata,howmany,raincol) { # a lazy way of getting the same structure

Re: [R] Loop problem

2008-03-27 Thread Jim Lemon
Jamie Ledingham wrote: > Dear all, I have a problem with a loop, if anyone has any knowledge on > these things I would appreciate some comments. The code below is > designed to allow me to extract the top record of the data frame, and > them remove rows from the data frame which have an index clos

Re: [R] Loop problem

2008-03-26 Thread jim holtman
Basically you are moving the data up and then incrementing to the next row. Here is an example; assume that you are at the 2nd entry: 1 2 <== here 3 4 Now your loop index is 2 and you remove the current data ('2') and are left with: 1 3 <== index of 2 points here 4 Now you increment the inde