Page 1 of 1

convert.inp or process.data

PostPosted: Tue Jun 07, 2022 10:06 am
by iwvining
I was recently updating an analyses using RMark. I did exactly what I've done before with:

Daisy<-convert.inp("390ckb.inp", group.df=data.frame(Grz.lbl=c("Grazed", "Ungrazed")))

followed by

Daisy.proc<-process.data(Daisy, model="RDOccupPG", groups="Grz.lbl",
time.intervals = c(0,1,0,0,1,0,0,1,0,0,1,0))

However, I get an error

In process.data(Daisy, model = "RDOccupPG", groups = "Grz.lbl", :
Grz.lbl is not a factor variable. Coercing to factor.

I re-ran it with the old data and got the same message. Has something changed? I did not see any other discussions of this.

Re: convert.inp or process.data

PostPosted: Wed Jun 08, 2022 3:05 pm
by jlaake
So R used to have stringsAsFactors set to TRUE which meant the code in convert.inp would have created a factor variable for Grz.lbl. But they changed that default to FALSE a few versions back. If you do str(Daisy) you will see that it is type chr for character. I added a Warning message (not an error) that if you pass it a character variable for groups that it is coercing it to type factor which it needs to be. No error here. If is just telling you that what you are passing is not a factor variable and that it is changing it to a factor variable.

Re: convert.inp or process.data

PostPosted: Wed Jun 08, 2022 10:36 pm
by jlaake
If you type

options (stringsAsFactors=TRUE)

before you call convert.inp it will work without the warning appearing. Either way it works.