Hi Phil
Try the following> which(names(iris)=='Species')
[1] 5
HTH
Schalk Heunis
On Mon, Oct 12, 2009 at 8:53 AM, tdm <philb@philbrierley.com> wrote:
>
> Hi,
>
> How do I access the index number of a field given I only know the field
> name?
>
> eg - I want to set the probability of the field 'species' higher
than the
> other fields to use in sampling.
>
> > colprob <- array(dim=NCOL(iris))
> > for(i in 1:NCOL(iris)){colprob[i]=0.5}
> > colprob[iris$species] = 1 #this doesn't work
> > colprob
> [1] 0.5 0.5 0.5 0.5 0.5
>
>
>
>
>
> --
> View this message in context:
> http://www.nabble.com/field-index-given-name.-tp25851216p25851216.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@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.
>
[[alternative HTML version deleted]]