Skip to content

Factor conversion

4 messages · Iker Vaquero Alba, Jarrod Hadfield, ONKELINX, Thierry

#
Hi, 

The argument to as.is has a spelling mistake perhaps: "bithrcoef" should
read "brithrcoef"?

You could also try as.numeric(as.character(x))

Jarrod
On Tue, 2011-06-07 at 23:14 +0100, Iker Vaquero Alba wrote:

  
    
1 day later
#
Dear Iker,

It looks like a problem with the txt file to me. You are expecting numerical values but you get characters instead. Use str() and summary() to check if your dataset contains what it should contain. If not, you need to find out what is going wrong. read.table choses the class of the variable depending on the data is finds for that variable. The least complex data class is used. But when you have one non-numerical data entry in a vector of numbers, then the whole vector will be converted to a character vector or factor.

So the problem is most likely not with the software but with your datafile.

Best regards,

Thierry

----------------------------------------------------------------------------
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey