[R] Problems with variable types.

Ronaldo Reis Jr. chrysopa at insecta.ufv.br
Thu Mar 6 15:46:28 CET 2003


Hi all,

I have problems in a dataframe variables types.

Look:

from a loop function:
for(...){
...
dados.fin <- rbind(dados.fin, c(L=j, A=j^2,
                                Nsp=nsps,
                                N=length(amosfin$SP),
                                AmT="am",NAm=nam,
                                AMST=amst))
dados.fin <- rbind(dados.fin, c(L=j, A=j^2,
                                Nsp=nsp, 
                                N=nbicho, AmT="tot",
                                NAm=nam,
                                AMST=amst))
...
}

    dados.fin <- as.data.frame(dados.fin)

> summary(dados.fin)
  L        A           Nsp           N       AmT     NAm      AMST   
 10:10   100:10   11     : 7   12     : 5   am :30   5:60   unif:60  
 12:10   144:10   7      : 7   122    : 5   tot:30                   
 14:10   196:10   16     : 5   181    : 5                            
 16:10   256:10   25     : 5   270    : 5                            
 18:10   324:10   37     : 5   403    : 5                            
 20:10   400:10   55     : 5   55     : 5                            
                  (Other):26   (Other):30                            

All variables appear like factors, but only AmT and AMST are really factors.

I try to use 

dados.fin <- rbind(dados.fin, c(L=as.numeric(j), A=j^2,
                                Nsp=nsp, 
                                N=nbicho, AmT="tot",
                                NAm=nam,
                                AMST=amst))

and some combinations like as.numeric(as.character(j)) etc.

How I make to force the types?

Thanks for all,

Ronaldo
-- 
Pessoas que são boas para arranjar desculpas raramente são boas em
qualquer outra coisa.
                -- Benjamim Franklin
--
|   // | \\   [*****************************][*******************]
|| ( õ   õ )  [Ronaldo Reis Júnior          ][PentiumIII-600     ]
|      V      [UFV/DBA-Entomologia          ][HD: 30 + 10 Gb     ]
||  /     \   [36571-000 Viçosa - MG        ][RAM: 128 Mb        ]
|  /(.''`.)\  [Fone: 31-3899-2532           ][Video: SiS620-8Mb  ]
||/(: :'  :)\ [chrysopa at insecta.ufv.br      ][Modem: Pctel-onboar]
|/ (`. `'` ) \[ICQ#: 5692561                ][Kernel: 2.4.18     ]
||  ( `-  )   [*****************************][*******************]
||| _/   \_Powered by GNU/Debian W/Sarge D+ || Lxuser#: 205366



More information about the R-help mailing list