Re: [R] Repeat if

2007-06-29 Thread Jim Lemon
Birgit Lemcke wrote: Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85) next + range (Vi, na.rm = TRUE) + if (i==85) break + } I presume that the Vi is wrong,

Re: [R] Repeat if

2007-06-29 Thread Birgit Lemcke
Hello Jim, thanks for your answer. At the moment I am using this code: Range0-sapply(1:85, function(i) eval(parse(text=paste(range(V, i, , na.rm=T), sep= and it works really fine. The code you sent me is also fine but how can I implement, that missing values are TRUE? Thanks a lot for

Re: [R] Repeat if

2007-06-29 Thread Christophe Pallier
On 6/29/07, Birgit Lemcke [EMAIL PROTECTED] wrote: Hello Jim, thanks for your answer. At the moment I am using this code: Range0-sapply(1:85, function(i) eval(parse(text=paste(range(V, i, , na.rm=T), sep= It is a matter of taste, but I tend to prefer: a - list() for (i in 1:85)

[R] Repeat if

2007-06-28 Thread Birgit Lemcke
Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85) next + range (Vi, na.rm = TRUE) + if (i==85) break + } I presume that the Vi is wrong, because in this syntax i is not known

Re: [R] Repeat if

2007-06-28 Thread Jacques VESLOT
sapply(1:85, function(i) eval(parse(text=paste(range(V, i, , na.rm=T), sep= Jacques VESLOT INRA - Biostatistique Processus Spatiaux Site Agroparc 84914 Avignon Cedex 9, France Tel: +33 (0) 4 32 72 21 58 Fax: +33 (0) 4 32 72 21 84 Birgit Lemcke a écrit : Hello, (Power Book G4, Mac OS

Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
Thanks that was really a quick answer. It works but I get this warning message anyway: 1: kein nicht-fehlendes Argument für min; gebe Inf zurück (None not- lacking argument for min; give Inf back) 2: kein nicht-fehlendes Argument für max; gebe -Inf zurück what does this mean? Greeting and

Re: [R] Repeat if

2007-06-28 Thread john seers \(IFR\)
: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Birgit Lemcke Sent: 28 June 2007 10:48 To: R Hilfe Subject: [R] Repeat if Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85

Re: [R] Repeat if

2007-06-28 Thread Christophe Pallier
Your V1 to V85 are probably coming from a data.frame, aren't they? If yes, and if this data.frame is named 'a', you can use 'sapply(a,range)' Otherwise, see ?get (get(paste(V,1,sep=)) returns V1) Christophe On 6/28/07, Birgit Lemcke [EMAIL PROTECTED] wrote: Hello, (Power Book G4, Mac OS X,

Re: [R] Repeat if

2007-06-28 Thread Jacques VESLOT
you may have a vector with only NA values in it... max(c(NA,NA), na.rm=T) [1] -Inf Warning message: aucun argument pour max ; -Inf est renvoyé Jacques VESLOT INRA - Biostatistique Processus Spatiaux Site Agroparc 84914 Avignon Cedex 9, France Tel: +33 (0) 4 32 72 21 58 Fax: +33 (0) 4 32 72 21

Re: [R] Repeat if

2007-06-28 Thread Peter Dalgaard
Birgit Lemcke wrote: Thanks that was really a quick answer. It works but I get this warning message anyway: 1: kein nicht-fehlendes Argument f�r min; gebe Inf zur�ck (None not- lacking argument for min; give Inf back) 2: kein nicht-fehlendes Argument f�r max; gebe -Inf zur�ck what does

Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
Thats not the case. I have two vectosr with a lot of NAs, but not only NAs. But nevertheless as i saw the results are accurate. Birgit Am 28.06.2007 um 15:17 schrieb Jacques VESLOT: you may have a vector with only NA values in it... max(c(NA,NA), na.rm=T) [1] -Inf Warning message:

Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
: [R] Repeat if Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85) next + range (Vi, na.rm = TRUE) + if (i==85) break + } Birgit Lemcke Institut für Systematische Botanik

Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
Thanks Christophe, I received already an answer with a similar suggestion. But thanks for your answer. Birgit Am 28.06.2007 um 12:34 schrieb Christophe Pallier: Your V1 to V85 are probably coming from a data.frame, aren't they? If yes, and if this data.frame is named 'a', you can use

Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
Hello Patrick, this does not work and gives following warning message: for(i in 1:85) range(get(paste(V, i, sep=)), na.rm=TRUE) Warning messages: 1: kein nicht-fehlendes Argument für min; gebe Inf zurück 2: kein nicht-fehlendes Argument für max; gebe -Inf zurück This works but also with the

Re: [R] Repeat if

2007-06-28 Thread john seers \(IFR\)
: 28 June 2007 15:12 To: john seers (IFR) Cc: R Hilfe Subject: Re: [R] Repeat if Hello John, I tried this code. But I got only the ranges of V1 and V2 what is easily understandable. Do I have to write in all 85 vectors in the first line? V-list(a=c(V1), b=c(V2)) for ( i in 1:85 ) { # 2

Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
Sorry Jacques and all the other helpful people! I made a mistake because I didn´t realize that I have a vector only containing NAs. That happened during standardization and i didn´t check this. I apologize for that. Greetings Birgit Am 28.06.2007 um 15:17 schrieb Jacques VESLOT: you may

[R] Repeat dataframe

2006-05-01 Thread Kenneth Cabrera
Hi R list: How can I repeat a data frame n times (with n1000), and obtain a new data frame where all the n data frames are binded by rows? Thank you for your help Kenneth -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ __

Re: [R] Repeat dataframe

2006-05-01 Thread Xiaohua Dai
Maybe the function merge is what you need. Xiaohua On 5/1/06, Kenneth Cabrera [EMAIL PROTECTED] wrote: Hi R list: How can I repeat a data frame n times (with n1000), and obtain a new data frame where all the n data frames are binded by rows? Thank you for your help Kenneth -- Using

Re: [R] Repeat dataframe

2006-05-01 Thread Xiaohua Dai
Sorry, I give a wrong answer. X On 5/1/06, Xiaohua Dai [EMAIL PROTECTED] wrote: Maybe the function merge is what you need. Xiaohua On 5/1/06, Kenneth Cabrera [EMAIL PROTECTED] wrote: Hi R list: How can I repeat a data frame n times (with n1000), and obtain a new data frame where

Re: [R] Repeat dataframe

2006-05-01 Thread Prof Brian Ripley
On Mon, 1 May 2006, Kenneth Cabrera wrote: Hi R list: How can I repeat a data frame n times (with n1000), and obtain a new data frame where all the n data frames are binded by rows? Perhaps my_df[rep(1:nrow(my_df), times=n), ] is what you want? -- Brian D. Ripley,

Re: [R] Repeat dataframe

2006-05-01 Thread Kenneth Cabrera
Well, I find a solution! If DFe is a data frame and n is an integer then DFr-data.frame(t(matrix(rep(t(DFe),n),dim(DFe)[2],dim(DFe)[1]*n))) names(DFr)-names(DFe) Will work!! Maybe somebody has a more elegant solution. Again, thank you for your help. On Mon, 01 May 2006 11:23:14 -0500,

Re: [R] Repeat dataframe

2006-05-01 Thread Kenneth Cabrera
As I said, a very more elegant solution! Thank you! On Mon, 01 May 2006 11:52:44 -0500, Prof Brian Ripley [EMAIL PROTECTED] wrote: my_df[rep(1:nrow(my_df), times=n), ] -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ __

Re: [R] repeat { readline() }

2006-01-09 Thread justin bem
--- Henrik Bengtsson [EMAIL PROTECTED] a écrit : Hi. Using Rterm v2.2.1 on WinXP, is there a way to interrupt a call like repeat { readline() } without killing the Command window? Ctrl+C is not interrupting the loop: To interupt the loop add and condition for a break like this :

Re: [R] repeat { readline() }

2006-01-09 Thread Luke Tierney
Use tryCatch; try behaves the way it does with respect to interrupts for historical compatibility. luke On Sun, 8 Jan 2006, hadley wickham wrote: On a related note, does anyone know how to exit: repeat { try( readline() ) } The try block captures Ctrl-C. Hadley

Re: [R] repeat { readline() }

2006-01-08 Thread Prof Brian Ripley
Ctrl-Break works: see the rw-FAQ and README.rterm. (You'll need a return to see a new prompt.) It is related to your reading directly from the console, so Ctrl-C is getting sent to the wrong place, I believe. (There's a comment from Guido somewhere in the sources about this, and this seems

Re: [R] repeat { readline() }

2006-01-08 Thread hadley wickham
On a related note, does anyone know how to exit: repeat { try( readline() ) } The try block captures Ctrl-C. Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!

Re: [R] repeat { readline() }

2006-01-08 Thread Prof Brian Ripley
On Sun, 8 Jan 2006, Prof Brian Ripley wrote: Ctrl-Break works: see the rw-FAQ and README.rterm. (You'll need a return to see a new prompt.) It is related to your reading directly from the console, so Ctrl-C is getting sent to the wrong place, I believe. (There's a comment from Guido

Re: [R] repeat { readline() }

2006-01-08 Thread Henrik Bengtsson
Prof Brian Ripley wrote: On Sun, 8 Jan 2006, Prof Brian Ripley wrote: Ctrl-Break works: see the rw-FAQ and README.rterm. (You'll need a return to see a new prompt.) It is related to your reading directly from the console, so Ctrl-C is getting sent to the wrong place, I believe. (There's

[R] repeat { readline() }

2006-01-07 Thread Henrik Bengtsson
Hi. Using Rterm v2.2.1 on WinXP, is there a way to interrupt a call like repeat { readline() } without killing the Command window? Ctrl+C is not interrupting the loop: R : Copyright 2006, The R Foundation for Statistical Computing Version 2.2.1 Patched (2006-01-01 r36947) snip/snip

[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] repeat until function

2003-11-12 Thread Ragnhild Sørum
Hi, I'm in this situation: I what to generate N random numbers(integer) that are different from each other. One suggestion: tabel - rep(NULL, N) for (i in 1:N){ temp - as.integer(runif(1,1,max)) if(temp in tabel) { repeat (?) (temp - as.integer(runif(i,i,max))) until (?) ((temp

Re: [R] repeat until function

2003-11-12 Thread Philipp Pagel
I what to generate N random numbers(integer) that are different from each other. One suggestion: tabel - rep(NULL, N) for (i in 1:N){ temp - as.integer(runif(1,1,max)) if(temp in tabel) { repeat (?) (temp - as.integer(runif(i,i,max))) until (?) ((temp in tabel) ==FALSE)

RE: [R] repeat until function

2003-11-12 Thread Liaw, Andy
Message- From: Ragnhild Sørum [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 12, 2003 9:26 AM To: [EMAIL PROTECTED] Subject: [R] repeat until function Hi, I'm in this situation: I what to generate N random numbers(integer) that are different from each other. One

RE: [R] repeat until function

2003-11-12 Thread Prof Brian Ripley
On Wed, 12 Nov 2003, Liaw, Andy wrote: As others already pointed out, the fast way is to use sample(). What I'd like to add is the following, which I learned from peeking at the C code underneath sample(): To draw n samples without replacement from 1:N (N=n), you only need a loop from 1 to

Re: [R] repeat until function

2003-11-12 Thread Peter Dalgaard
Liaw, Andy [EMAIL PROTECTED] writes: This is obviously not efficient in high-level languages like R, but in terms of algorithm, it is a lot more efficient than check-and-reject. IMHO this should be described in some book, but I have not seen any book describing it. I'm pretty sure I have -

Re: [R] repeat until function

2003-11-12 Thread Duncan Murdoch
On Wed, 12 Nov 2003 12:00:06 -0500, Liaw, Andy [EMAIL PROTECTED] wrote : This is obviously not efficient in high-level languages like R, but in terms of algorithm, it is a lot more efficient than check-and-reject. IMHO this should be described in some book, but I have not seen any book

RE: [R] repeat until function

2003-11-12 Thread Liaw, Andy
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Ripley (1987) Stochastic Simulation, pp.80-1 for one. I am pretty sure it is Knuth's book, although I don't have that to hand. I attribute it to Moses Oakford (1963). Thanks to Brian, Peter and Duncan for the info. And I have both