[R] field index given name.

tdm philb at philbrierley.com
Mon Oct 12 08:53:18 CEST 2009


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.




More information about the R-help mailing list