Thank you Christian.

Following your suggestion I got the following result,

 > pa2 = subset(pa, influencia=="AP")
 > pa2$influencia<-as.factor(pa2$influencia)
 > levels(pa$influencia)
[1] "AID" "AII" "AP"


On 24/04/2011 07:42 a.m., Christian Parker wrote:
> You are creating a new object, but the columns that are stored as factors are 
> not being 'refactored' so you are retaining the original list of levels. To 
> fix this you can use the factor function after you subset
>
> pa2 = subset(pa, influencia=="AID")
> pa2$influencia<-as.factor(pa2$influencia)
>
>
>
> On Apr 24, 2011, at 6:04 AM, Manuel Spínola<mspinol...@gmail.com>  wrote:
>
>> Dear list members,
>>
>> I have a question regarding too subsetting a data set in R.
>>
>> I created an object for my data:
>>
>>> pa = read.csv("espec_indic.csv", header = T, sep=",", check.names = F)
>>> levels(pa$influencia)
>> [1] "AID" "AII" "AP"
>>
>> The object has 3 levels for influencia (AP, AID, AII)
>>
>> Now I subset only observations with influencia = "AID"
>>
>>> pa2 = subset(pa, influencia=="AID")
>> but if I ask for the levels of influencia still show me the 3 levels,
>> AP, AID, AII.
>>
>>> levels(pa2$influencia)
>> [1] "AID" "AII" "AP"
>>
>> Why is that?
>>
>> I was thinking that I was creating a new data frame with only AID as a
>> level for influencia.
>>
>> How can I make a complete new object with only the observations for
>> "AID" and that the only level for influencia is indeed "AID"?
>>
>> Best,
>>
>> Manuel
>>
>>
>>
>>
>> -- 
>> *Manuel Spínola, Ph.D.*
>> Instituto Internacional en Conservación y Manejo de Vida Silvestre
>> Universidad Nacional
>> Apartado 1350-3000
>> Heredia
>> COSTA RICA
>> mspin...@una.ac.cr
>> mspinol...@gmail.com
>> Teléfono: (506) 2277-3598
>> Fax: (506) 2237-7036
>> Personal website: Lobito de río
>> <https://sites.google.com/site/lobitoderio/>
>> Institutional website: ICOMVIS<http://www.icomvis.una.ac.cr/>
>>
>>     [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-ecology mailing list
>> R-sig-ecology@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.ac.cr
mspinol...@gmail.com
Teléfono: (506) 2277-3598
Fax: (506) 2237-7036
Personal website: Lobito de río 
<https://sites.google.com/site/lobitoderio/>
Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Reply via email to