gl.recode.pop bug

73 views
Skip to first unread message

Berry, Olly (NCMI, IOMRC Crawley)

unread,
Jan 12, 2021, 4:26:30 AM1/12/21
to da...@googlegroups.com

Hi,

 

I’m having trouble renaming my sites in my genlight file with the gl.recode.pop function, and wonder if there is a bug? I get the same error for both my data and also bandicoot.gl or testset.gl.

 

I can create a draft recode table via the gl.make.recode.pop function and edit it in excel, or even RStudio. However, when I use it to run gl.recode.pop my pops are labelled as numbers. The function seems to be treating them as factors. I even get the error if I don’t edit the recode table.

 

I can repeat the whole process, but recoding individuals with the very similar gl.recode.ind function and have no problem.

 

Delving inexpertly into some of the code for these two functions, one difference I see is that @ line 83 gl.recode.ind sets stringsAsFactors=FALSE, whereas gl.recode.pop has stringsAsFactors = TRUE @ line 87. If I edit that code to be stringsAsFactors = TRUE and rerun using my edited version of the function, I seem to be able to get it to work properly.

 

What do you think Arthur/Bernd?

 

Cheers,

 

Olly

 

 

My code is as follows:

gl.make.recode.pop(working.gl, out.recode.file = "testpop.csv", outpath = getwd())

working.gl <- gl.recode.pop(working.gl, pop.recode = "testpop.csv", recalc = FALSE, mono.rm = FALSE, verbose = 5)

levels(working.gl$pop)

 

 

 

Bernd.Gruber

unread,
Jan 13, 2021, 6:35:01 PM1/13/21
to da...@googlegroups.com

Hi Olly,

 

This seems to be an error that came in with R 4. Because here the default is stringsAsFactors = FALSE when using read.csv, which is not what you want in most cases from our point of view. Here I think we made a mistake and it needs be set to FALSE as you suggested.

 

Will be in the next update (Luis is starting the coming week 😊)

 

Cheers, Bernd

 

 

 

==============================================================================

Dr Bernd Gruber                                              )/_         

                                                         _.--..---"-,--c_    

Professor Ecological Modelling                      \|..'           ._O__)_     

Tel: (02) 6206 3804                         ,=.    _.+   _ \..--( /          

Fax: (02) 6201 2328                           \\.-''_.-' \ (     \_          

Institute for Applied Ecology                  `'''       `\__   /\          

Faculty of Science and Technology                          ')                

University of Canberra   ACT 2601 AUSTRALIA

Email: bernd....@canberra.edu.au

WWW: bernd-gruber

 

Australian Government Higher Education Provider Number CRICOS #00212K 

NOTICE & DISCLAIMER: This email and any files transmitted with it may contain
confidential or copyright material and are for the attention of the addressee
only. If you have received this email in error please notify us by email
reply and delete it from your system. The University of Canberra accepts
no liability for any damage caused by any virus transmitted by this email.

==============================================================================

--
You received this message because you are subscribed to the Google Groups "dartR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dartr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dartr/MEAPR01MB2502641D3687DB29ABD5151EFFAA0%40MEAPR01MB2502.ausprd01.prod.outlook.com.

Arthur Georges

unread,
Jan 13, 2021, 8:05:49 PM1/13/21
to da...@googlegroups.com
Yes, R changed the default, and we had to go through all scripts to resolve. Seems like we made a mistake with this one. Will fix for the next version.



Reply all
Reply to author
Forward
0 new messages