Dear all, I am a newbie to R and practising at the moment. Here is my problem: I have a programme with 2 loops involved. The inner loop get me matrices as output and safes all values for me. Now once I wrote a 2nd loop around the other loop in order to repeat the inner loop a couple of times, the results are overwritten and i found no way how to actually put the output results in a vector. I can receive single results only, like this [1] number [1] number2 .... but it want it rather like this [1] number number2 number3 ... any advice? Thanks unbekannter weise -- View this message in context: http://www.nabble.com/Problem-with-Loop-and-overwritten-results-tp23013391p23013391.html Sent from the R help mailing list archive at Nabble.com.
Dear unbekannt; The construction that would append a number to a numeric vector would be: vec <- c(vec , number) You can create an empty vector with vec <- c() or vec <- NULL -- David Winsemius On Apr 12, 2009, at 2:10 PM, unbekannt wrote:> > > Dear all, > > I am a newbie to R and practising at the moment. > > Here is my problem: > > I have a programme with 2 loops involved. > The inner loop get me matrices as output and safes all values for me. > > Now once I wrote a 2nd loop around the other loop in order to > repeat the inner loop a couple of times, the results are overwritten > and > i found no way how to actually put the output results in a vector. > > I can receive single results only, like this > > [1] number > [1] number2 > .... > > but it want it rather like this > > [1] number number2 number3 ... > > any advice? > > Thanks > unbekannter weise > > > -- > View this message in context: http://www.nabble.com/Problem-with-Loop-and-overwritten-results-tp23013391p23013391.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD Heritage Laboratories West Hartford, CT
thank you so much! this solved my problem unbekannt wrote:> > > Dear all, > > I am a newbie to R and practising at the moment. > > Here is my problem: > > I have a programme with 2 loops involved. > The inner loop get me matrices as output and safes all values for me. > > Now once I wrote a 2nd loop around the other loop in order to > repeat the inner loop a couple of times, the results are overwritten and > i found no way how to actually put the output results in a vector. > > I can receive single results only, like this > > [1] number > [1] number2 > .... > > but it want it rather like this > > [1] number number2 number3 ... > > any advice? > > Thanks > unbekannter weise > > >:clap: -- View this message in context: http://www.nabble.com/Problem-with-Loop-and-overwritten-results-tp23013391p23019655.html Sent from the R help mailing list archive at Nabble.com.