HI, Dear community,
I am building the following loop,
ww<-function(file) {
lossw<-vector()
for (x in seq(0.1, 0.9, by=0.1)) {
cat('xweight ', x, '\n')
lossw[i] <- cross.validation(file, x)$avg
}
return(lossw) }
MY question is how to index the lossw[i]?
for (i in 1:9)
for (x in seq(0.1, 0.9, by=0.1))
Thanks so much!
--
Sincerely,
Changbin
--
[[alternative HTML version deleted]]
Thanks so much, Marius! It works! On Thu, Apr 15, 2010 at 1:35 PM, Marius 't Hart <M.t.Hart@ai.rug.nl> wrote:> lossw[i] <- cross.validation(file, x)$avg > > change to: > > lossw <- append(lossw,cross.validation(file, x)$avg) > > > > > Changbin Du wrote: > >> HI, Dear community, >> >> I am building the following loop, >> >> ww<-function(file) { >> lossw<-vector() >> for (x in seq(0.1, 0.9, by=0.1)) { >> cat('xweight ', x, '\n') >> >> lossw[i] <- cross.validation(file, x)$avg >> >> } >> return(lossw) } >> >> >> MY question is how to index the lossw[i]? >> >> >> >> for (i in 1:9) >> for (x in seq(0.1, 0.9, by=0.1)) >> >> >> >> Thanks so much! >> >> >> > >-- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[alternative HTML version deleted]]
On Apr 15, 2010, at 4:24 PM, Changbin Du wrote:> HI, Dear community, > > I am building the following loop, > > ww<-function(file) { > lossw<-vector() > for (x in seq(0.1, 0.9, by=0.1)) { > cat('xweight ', x, '\n') > > lossw[i] <- cross.validation(file, x)$avg > > } > return(lossw) } > > > MY question is how to index the lossw[i]?Perhaps lossw[round(x*10)]> > > > for (i in 1:9) > for (x in seq(0.1, 0.9, by=0.1))David Winsemius, MD West Hartford, CT