
   Thank you very much, Thierry. Certainly, the problem was with the txt file 
and the attachment. Renaud told me to change the decimal commas to dots, I did 
it and it worked, and am happily doing my analyses now. 


   Thank you very much again to everyone.




________________________________
De: "ONKELINX, Thierry" <Thierry.ONKELINX@inbo.be>

"r-sig-mixed-models@r-project.org" <r-sig-mixed-models@r-project.org>
Enviado: jue,9 junio, 2011 11:12
Asunto: RE: [R-sig-ME] Factor conversion

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@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

> -----Oorspronkelijk bericht-----
> Van: r-sig-mixed-models-bounces@r-project.org [mailto:r-sig-mixed-models-
> bounces@r-project.org] Namens Iker Vaquero Alba
> Verzonden: woensdag 8 juni 2011 0:14
> Aan: r-sig-mixed-models@r-project.org
> Onderwerp: [R-sig-ME] Factor conversion
> 
> 
> 
>    Dear R list:
> 
>    I am fitting a model where I have several covariates which are coefficients 
>of
> variation. For some reason, the software interprets them as factors. I was
> converting them with the function "as.numeric", but when doing so, the 
variable
> is converted into an ordinal categorical one.
>    I have tried the “as.is” function but I get this message:
> 
> In read.table("Coefvar insects 2009+2010.txt", header = T, as.is = 
"bithrcoef")
> :
>   not all columns named in 'as.is' exist
> 
>    Could you tell me wich is the most suitable converting function I should 
>use?
> I’ve tried “as.vector” and “as.character”, but I get this error messages when
> fitting the model with lme or lmer:
>    With lmer:
> 
> “insectmodel2<-
> lmer(inslarge~tlengthcoef+brivencoef+brithrcoef+condcoef+sex+tlengthcoef:se
> x+brivencoef:sex+brithrcoef:sex+condcoef:sex+tlengthcoef:brivencoef+tlengthc
> oef:brithrcoef+tlengthcoef:condcoef+brivencoef:brithrcoef+brivencoef:condco
> ef+brithrcoef:condcoef+(1|year))”
> 
>    Error in mer_finalize(ans) : Downdated X'X is not positive definite, 35.
> Also: lost warning messages
> 1: In model.matrix.default(mt, mf, contrasts) :
>   variable 'tlengthcoef' converted to a factor
> 2: In model.matrix.default(mt, mf, contrasts) :
>   variable 'brivencoef' converted to a factor
> 3: In model.matrix.default(mt, mf, contrasts) :
>   variable 'brithrcoef' converted to a factor
> 4: In model.matrix.default(mt, mf, contrasts) :
>   variable 'condcoef' converted to a factor
> 
>    With lme:
> 
> “insectmodel2<-
> lme(inslarge~tlengthcoef+brivencoef+brithrcoef+condcoef+sex+tlengthcoef:sex
> +brivencoef:sex+brithrcoef:sex+condcoef:sex+tlengthcoef:brivencoef+tlengthc
> oef:brithrcoef+tlengthcoef:condcoef+brivencoef:brithrcoef+brivencoef:condco
> ef+brithrcoef:condcoef,random=~1|year)”
> 
> Error in MEEM(object, conLin, control$niterEM) :
>   Singularity in backsolve at level 0, block 1
> Also: Lost warning messages
> 1: In model.matrix.default(fixed, data = X) :
>   variable 'tlengthcoef' converted to a factor
> 2: In model.matrix.default(fixed, data = X) :
>   variable 'brivencoef' converted to a factor
> 3: In model.matrix.default(fixed, data = X) :
>   variable 'brithrcoef' converted to a factor
> 4: In model.matrix.default(fixed, data = X) :
>   variable 'condcoef' converted to a factor
> 
> 
>    Any help will be greatly appreciated.
> 
>    Thank you very much. Iker
>     [[alternative HTML version deleted]]
	[[alternative HTML version deleted]]


