Varsha Agrawal wrote on 09/07/2011 05:18:10 AM:
> 
> The code looks like this:
> L1=list(a=1,b=2,c=3)
> f1=as.factor(c)
> L1[[f1]] returns 1
> 
> What happens if we give a factor as an index at a list?
> 


L1=list(a=1,b=2,c=3)
f1=as.factor(L1$c)
L1[[f1]]

When you use a factor (e.g., f1, corrected example above) as an index, the 
factor is converted to an integer,

as.integer(f1)

This is spelled out in the help file for the extract function in the 
explanation of arguments i, j, ...

?"["

This results in essentially the level number of the factor.  Since there 
is only one level (the level "3") in f1, the level number is 1.

Does that help?

Jean
	[[alternative HTML version deleted]]

