Re: [R] Create a new variable and concatenation inside a "for" loop

2016-05-02 Thread Rolf Turner
hard Raubertas -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of JeffNewmiller Sent: Wednesday, April 27, 2016 3:58 PM To: Gordon, Fabiana; 'r-help@R-project.org' Subject: Re: [R] Create a new variable and concatenation inside a "for&quo

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-05-02 Thread Tom Wright
As pointed out somewhere in the replies to this you can always use the exists() function. for(i in 1:5){ if(exists(output)){ output <- c(output, i ) }else{ output <- i } } On Wed, Apr 27, 2016, 11:15 AM Gordon, Fabiana < fabiana.gor...@imperial.ac.uk> wrote: > Hello, > >

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-05-02 Thread Raubertas, Richard
nal Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Newmiller Sent: Wednesday, April 27, 2016 3:58 PM To: Gordon, Fabiana; 'r-help@R-project.org' Subject: Re: [R] Create a new variable and concatenation inside a "for" loop "c" an extre

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-04-28 Thread David Winsemius
> On Apr 28, 2016, at 4:51 AM, Gordon, Fabiana > wrote: > > > Maybe I wasn't clear about my query. > > I'm very familiar with pre-allocation and vectorization and I had already > wrote an R code for this problem in this way. My question wasn't about the > most efficient way to solve the

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-04-28 Thread MacQueen, Don
;From: Bert Gunter [mailto:bgunter.4...@gmail.com] >Sent: 27 April 2016 21:18 >To: Jeff Newmiller >Cc: Gordon, Fabiana; r-help@R-project.org >Subject: Re: [R] Create a new variable and concatenation inside a "for" >loop > >... > >"(R is case sensitive, so

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-04-28 Thread Gordon, Fabiana
ssage- From: Bert Gunter [mailto:bgunter.4...@gmail.com] Sent: 27 April 2016 21:18 To: Jeff Newmiller Cc: Gordon, Fabiana; r-help@R-project.org Subject: Re: [R] Create a new variable and concatenation inside a "for" loop ... "(R is case sensitive, so "C" has no such proble

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-04-27 Thread Bert Gunter
... "(R is case sensitive, so "C" has no such problem)." Well, not quite. Try ?C To add to the previous comments, Dr. Gordon appears to need to do her/his homework and spend some time with an R tutorial or two before posting further here. There are many good ones on the web. Some recommendations

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-04-27 Thread Jeff Newmiller
"c" an extremely commonly-used function. Functions are first-class objects that occupy the same namespaces that variables do, so they can obscure each other. In short, don't use variables called "c" (R is case sensitive, so "C" has no such problem). Wherever possible, avoid incremental concaten

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-04-27 Thread David L Carlson
352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Gordon, Fabiana Sent: Wednesday, April 27, 2016 9:25 AM To: 'r-help@R-project.org' Subject: [R] Create a new variable and concatenation inside a "for" loop Hello, Suppose the you need a

[R] Create a new variable and concatenation inside a "for" loop

2016-04-27 Thread Gordon, Fabiana
Hello, Suppose the you need a loop to create a new variable , i.e., you are not reading data from outside the loop. This is a simple example in Matlab code, for i=1:5 r1=randn r2=randn r=[r1 r2] c(i,:)=r; % creation of each row of c , % the ":" symbol indicates all columns. In R this would be