Hi all, I'm using a certain procedure to calculate the value of some variable(Bayes risk),B. So I got the values B1, B2, ........, B1000, each under certain input values and using a long procedure. Now, I want to put the values I got in a nummerical vector and find their minimum value. I think c( ) should work.For example if I have only 10 values I could have used c(B1,B2,B3,B4,B5,B6,B7,B8,B9,B10) But how can I do this for 1000 values? I think the question is really trivial, but I tried to work on it and couldn't reach anythg. Thanks. Maram [[alternative HTML version deleted]]
On Mon, 7 Sep 2009, maram salem wrote:> Hi all, > I'm using a certain? procedure to calculate the value of some variable(Bayes risk),B. > So I got the values B1, B2, ........, B1000, each under certain input values and using a long procedure. > Now, I want to put the values I got in a nummerical vector?and find their minimum value. I?think c( ) should work.For example if I have only 10 values I could have used > c(B1,B2,B3,B4,B5,B6,B7,B8,B9,B10) > But how can I do this for 1000 values?sapply( paste( "B", 1:1000, sep='' ), get ) but I wonder why you didn't store the values in a list to start with. HTH, Chuck> I think the question is really trivial, but I tried to work on it and couldn't reach anythg. > Thanks. > Maram > > > > [[alternative HTML version deleted]] > >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
Hi, If I correctly understand what you want to do, then this might work:> tmp <- rep(0, times=1000) > for (i in 1:1000) tmp[i] <- get(paste('B', i, sep='')) > mean(tmp)HTH, Vik maram salem wrote:> > Hi all, > I'm using a certain? procedure to calculate the value of some > variable(Bayes risk),B. > So I got the values B1, B2, ........, B1000, each under certain input > values and using a long procedure. > Now, I want to put the values I got in a nummerical vector?and find their > minimum value. I?think c( ) should work.For example if I have only 10 > values I could have used > c(B1,B2,B3,B4,B5,B6,B7,B8,B9,B10) > But how can I do this for 1000 values? > I think the question is really trivial, but I tried to work on it and > couldn't reach anythg. > Thanks. > Maram > > > > [[alternative HTML version deleted]] > > > ______________________________________________ > 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. > >-- View this message in context: http://www.nabble.com/finding-the-minimum-value-tp25332756p25336385.html Sent from the R help mailing list archive at Nabble.com.
Possibly Parallel Threads
- cdf
- axis label
- The code itself disappears after starting to execute the for loop
- The code itself disappears after starting to execute the for loop
- Strange behavior when using progress bar (Fwd: Re: [R] The code itself disappears after starting to execute the for loop)