[R] r-loop

David Winsemius dwinsemius at comcast.net
Thu Apr 15 22:41:51 CEST 2010


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



More information about the R-help mailing list