Re: [R] using loops to create multiple images

2007-08-05 Thread Stephen Tucker
Not sure exactly what 'results' is doing there or 'barplot(table(i),...)' does [see ?table] but I think this is sort of what you want to do? ## Variable assignment G01_01 - 1:10 G01_02 - 2:6 ## Combine to list* varnames - paste(G01_,substring(100+1:2,2),sep=) vars -

Re: [R] using loops to create multiple images

2007-08-05 Thread Deepayan Sarkar
On 8/4/07, Donatas G. [EMAIL PROTECTED] wrote: I have a data.frame with ~100 columns and I need a barplot for each column produced and saved in some directory. I am not sure it is possible - so please help me. this is my loop that does not work... vars - list (substitute (G01_01),

[R] using loops to create multiple images

2007-08-04 Thread Donatas G.
I have a data.frame with ~100 columns and I need a barplot for each column produced and saved in some directory. I am not sure it is possible - so please help me. this is my loop that does not work... vars - list (substitute (G01_01), substitute (G01_02), substitute (G01_03), substitute

Re: [R] using loops to create multiple images

2007-08-04 Thread Jeffrey Horner
it an int. Also, be sure to read up on the apply family of functions as an alternative to using loops in R code. Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r

Re: [R] For loops

2007-07-26 Thread Patrick Burns
Any time you are calling a function one value at a time, it is worth asking if you can eliminate a loop (or more). If 'G.fun' is vectorized in its first argument, then you can easily get rid of the three inner loops. Just generate a vector of all of the values and do: gj -

[R] For loops

2007-07-25 Thread Joaquim J. S. Ramalho
Hi, is there a way of simplifying the following code: G - rep(NA,n) for(i in 1:n) { gj - 0 for(j in 1:n) { for(l in 1:n) { for(m in 1:n) { gj - gj+G.fun(XB[i]+p[3]*X[j,3]+p[4]*X[l,4]+p[5]*X[m,5],ff) } } } G[i] - gj/n^3 } Thanks. Joaquim Santos __

[R] for loops

2007-04-25 Thread [EMAIL PROTECTED]
Hello everybody I'm very new at using R so probably this is a very stupid question. I have a matrix of p columns and I have to calculate for each of them the two sample t-statistic and p-value and to save the results into two different vectors. I have divided my matrix into two submatrices:

[R] for loops and counter interpolation

2006-05-17 Thread e . rapsomaniki
Hi I'm sorry about the triviality of my problem. I have a vector (v) of three columns (logA, logB, id). I want to compute (and plot) the correlation between logA and logB for different thresholds of id (e.g. 30, etc). So I tried: for(i in 1:100){ points(cor(v$logA[v$idi], v$logB[v$idi],

Re: [R] for loops and counter interpolation

2006-05-17 Thread Sarah Goslee
Hello, I think you are trying to combine too many things into one. for(i in 1:100){ points(cor(v$logA[v$idi], v$logB[v$idi], use=complete.obs), i)) } (i created a plot object already) For points() you need to have x and y, but you are giving the output of cor() This will plot your data

Re: [R] avoiding loops

2005-01-29 Thread Frank Samuelson
to calculate the distance from each point in the one frame to every point in the second... But how to do this without loops, how to do it quickly? I would appreciate it very much, if someone would introduce me to the high art of R - avoiding loops :-). Cheers, Dax

Re: [R] avoiding loops

2005-01-29 Thread Gabor Grothendieck
From: Frank Samuelson [EMAIL PROTECTED] Along the lines of this thread, is there a general apply type function that allows me to take one vector at a time from a matrix (or row from a data frame) and another vector from another matrix and apply them on a general function? Sort of a

[R] avoiding loops

2005-01-28 Thread dax42
- avoiding loops :-). Cheers, Dax. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

RE: [R] avoiding loops

2005-01-28 Thread Liaw, Andy
from each point in the one frame to every point in the second... But how to do this without loops, how to do it quickly? I would appreciate it very much, if someone would introduce me to the high art of R - avoiding loops :-). Cheers, Dax

RE: [R] avoiding loops

2005-01-28 Thread Liaw, Andy
- avoiding loops :-). Cheers, Dax. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

[R] R: repeat loops

2004-12-28 Thread Michael Gray
To whoever this may concern I am trying to write a repeat loop and can't make out from the documentation on the website how exactly to construct the repeat, break structure of the loop. Below is the function sim2.dat that I am trying to create, in which firstly I create n random uniform(0,1)

Re: [R] R: repeat loops

2004-12-28 Thread Ale iberna
[j]F){break} } u[j]-k } u } - Original Message - From: Michael Gray [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Sent: Tuesday, December 28, 2004 12:47 PM Subject: [R] R: repeat loops To whoever this may concern I am trying to write a repeat loop and can't make out from

[R] Re : LOOPS

2004-12-05 Thread ssim
Dear lists, I want to construct a loop in R, but don't know how to do it. I can do it in SAS, but I prefer in R (which I am hoping I will off SAS for good soon). Could anyone help me to convert the SAS codes to equivalent R codes. Basically, the following codes were written to establish the

[R] Re : LOOPS

2004-12-05 Thread ssim
Thanks Peter. Basically, I am trying to establish the line of marker allele the progeny has inherited from either the sire or the dam. The progeny will share the sires but each have different dam (ie., daughter design or half-sib model). The SAS code I have written to identify the lines of

Re: [R] Re : LOOPS

2004-12-05 Thread Yuandan Zhang
On Mon, 6 Dec 2004 13:36:37 +1300 [EMAIL PROTECTED] wrote: Dear lists, I want to construct a loop in R, but don't know how to do it. I can do it in SAS, but I prefer in R (which I am hoping I will off SAS for good soon). Could anyone help me to convert the SAS codes to equivalent R codes.

[R] If loops

2004-10-03 Thread Laura Collins
Hi, I'm a complete beginner to all this so I was hoping someone could help me! What I'm trying to do is to write a function that returns the coordinates where a vector x is equal to a. So say I invent a vector x: x-c(,5,8,9,8,3). If a is a-8. I want the function to return the

Re: [R] If loops

2004-10-03 Thread Uwe Ligges
Laura Collins wrote: Hi, I'm a complete beginner to all this so I was hoping someone could help me! What I'm trying to do is to write a function that returns the coordinates where a vector x is equal to a. So say I invent a vector x: x-c(,5,8,9,8,3). If a is a-8. I want the function to

RE: [R] If loops

2004-10-03 Thread Liaw, Andy
From: Laura Collins Hi, I'm a complete beginner to all this so I was hoping someone could help me! What I'm trying to do is to write a function that returns the coordinates where a vector x is equal to a. So say I invent a vector x: x-c(,5,8,9,8,3). If a is a-8. I want the

[R] slow loops in Monte Carlo Simulations

2004-09-28 Thread Nael Al Anaswah
Hi there, I am running Monte Carlo Simulations in R using ordinary while (condition) loops. Since the number of iterations is something like 100.000 and within each iteration a given subsample is extended sequentially it takes hours to run the simulation. Does anyone know if there is either

Re: [R] slow loops in Monte Carlo Simulations

2004-09-28 Thread Duncan Murdoch
On Tue, 28 Sep 2004 13:46:04 +0200, Nael Al Anaswah [EMAIL PROTECTED] wrote : Hi there, I am running Monte Carlo Simulations in R using ordinary while (condition) loops. Since the number of iterations is something like 100.000 and within each iteration a given subsample is extended

Re: [R] slow loops in Monte Carlo Simulations

2004-09-28 Thread Witold Eryk Wolski
Hi! Have you taken a look at the MCMCpack - package on cran: This package contains functions for posterior simulation for a number of statistical models. All simulation is done in compiled C++ written in the Scythe Statistical Library Version 1.0. All models return coda mcmc objects that can

Re: [R] slow loops in Monte Carlo Simulations

2004-09-28 Thread Gardar Johannesson
The key is to assign space in advance -- e.g., compare: N - 2 res - NULL system.time( for(i in 1:N) res - c(res, sample(10)) ) [1] 28.62 8.91 37.79 0.00 0.00 res - vector(list,N) system.time( for(i in 1:N) res[[i]] - sample(10) ) [1] 0.45 0.00 0.44 0.00 0.00 res - matrix(0.0, N,10)

[R] avoiding loops?

2004-09-26 Thread Christian Schulz
Hi, is it possible doing this moving average without a loop, because it is not really fast for dim(x) 300.000 50. I make some attempts with apply and sapply,but didn't get success until now. many thanks , christian ma - function(x, FUN=mean, lag=5) { FUN=match.fun(FUN)

Re: [R] avoiding loops?

2004-09-26 Thread Uwe Ligges
Christian Schulz wrote: Hi, is it possible doing this moving average without a loop, because it is not really fast for dim(x) 300.000 50. On the other hand, building a matrix before consumes too much memory. The best way of doing it is using an already existing function (you might want to

[R] avoiding loops

2004-06-25 Thread Anne Piotet
Hi R-helpers! I'd like to compute the values x(i)-x(n-i-1) for i=1 n/2 or similar (as way of testing distribution symmetry hypothesis). It is very easy to do that with a loop but can that be avoided? Thanks Anne [[alternative HTML version deleted]]

Re: [R] avoiding loops

2004-06-25 Thread Prof Brian Ripley
On Fri, 25 Jun 2004, Anne Piotet wrote: I'd like to compute the values x(i)-x(n-i-1) for i=1 n/2 or similar (as way of testing distribution symmetry hypothesis). It is very easy to do that with a loop but can that be avoided? Is that really what you want (not x[n-i+1])? x - rev(x) gives

[R] understanding loops for loop-plotting

2004-02-16 Thread Christian Schulz
Hi, i make some practice on loops to understand this important issue in difference to the wrappers like apply finally! The point is that i want plot's for different different const and wish in one pdf the 5 plots . So i want plots for const=1:5 which change the undelying data expressed in

Re: [R] understanding loops for loop-plotting

2004-02-16 Thread Paul Murrell
Hi If you make the pdf() call BEFORE entering the loop does it do what you want? Paul Christian Schulz wrote: Hi, i make some practice on loops to understand this important issue in difference to the wrappers like apply finally! The point is that i want plot's for different different const

Re: [R] understanding loops for loop-plotting

2004-02-16 Thread Christian Schulz
yes, yesterday when i go to sleep i recognize my stupid error! Thanks,Christian Am Dienstag, 17. Februar 2004 03:42 schrieb Paul Murrell: Hi If you make the pdf() call BEFORE entering the loop does it do what you want? Paul Christian Schulz wrote: Hi, i make some practice on loops

[R] for loops?

2004-02-02 Thread Catherine Stein
Hello R people! How can one use a for loop (or something similar) in R? As I type in each line, I get syntax errors... I'm just confused how much to type in at each prompt. Thanks for your help, cathy ~~~ Catherine

Re: [R] for loops?

2004-02-02 Thread Pedro Rodrigues
On Mon, 2004-02-02 at 13:42, Catherine Stein wrote: Hello R people! How can one use a for loop (or something similar) in R? As I type in each line, I get syntax errors... I'm just confused how much to type in at each prompt. Thanks for your help, cathy Hello. I believe you want

Re: [R] for loops?

2004-02-02 Thread Barry Rowlingson
Catherine Stein wrote: How can one use a for loop (or something similar) in R? As I type in each line, I get syntax errors... I'm just confused how much to type in at each prompt. Have you read help(for) (you need to quote 'for' here to avoid a syntax error!)? If you'd shown us exactly what

Re: [R] for loops?

2004-02-02 Thread Petr Pikal
Hi On 2 Feb 2004 at 8:42, Catherine Stein wrote: Hello R people! How can one use a for loop (or something similar) in R? As I type in each line, I get syntax errors... I'm just confused how much to type Use curly braces for (i in ...) { your long commands in several lines } An

[R] Constructing loops in which i+1st element depends on ith

2003-06-30 Thread Michael Rennie
I feel greedy posting for help twice in one day- please forgive me, but the thesis can't wait. I have been trying to get an “if…else” statement working in a loop I am writing, in which I specify a variable value to 9.2 (Wo) on the first iteration, but for subsequent iterations, to adopt a