convert.inp or process.data

posts related to the RMark library, which may not be of general interest to users of 'classic' MARK

convert.inp or process.data

Postby iwvining » Tue Jun 07, 2022 10:06 am

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.
iwvining
 
Posts: 5
Joined: Thu Feb 02, 2012 12:03 pm

Re: convert.inp or process.data

Postby jlaake » Wed Jun 08, 2022 3:05 pm

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.
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: convert.inp or process.data

Postby jlaake » Wed Jun 08, 2022 10:36 pm

If you type

options (stringsAsFactors=TRUE)

before you call convert.inp it will work without the warning appearing. Either way it works.
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA


Return to RMark

Who is online

Users browsing this forum: No registered users and 12 guests