[R] Partial matching list elements in R 4.0

John Harrold john@m@h@rro|d @end|ng |rom gm@||@com
Wed May 27 22:13:25 CEST 2020


Thankyou Bert and Bill.

I have one last question. Is there a tool that will recursively compare two
lists to find differences in both their structure and contents?

I'm afraid that in the process of converting code from $ to [[]] formats I
may inadvertently introduce some errors. And I'd like to QC it in some way.

Thanks
John

On Tue, May 26, 2020 at 11:33 AM William Dunlap <wdunlap using tibco.com> wrote:

> Another symptom of this problem is:
>
> > {x <- list(Abc=list(Pqr="Old Abc$Pqr")); x$Ab$Pqr <- "New Ab$Pqr" ; x}
> R version 3.6.2 (2019-12-12) | R version 4.0.0 (2020-04-24)
> List of 2                    | List of 2
>  $ Abc:List of 1             |  $ Abc:List of 1
>   ..$ Pqr: chr "Old Abc$Pqr" |   ..$ Pqr: chr "New Ab$Pqr"
>  $ Ab :List of 1             |  $ Ab :List of 1
>   ..$ Pqr: chr "New Ab$Pqr"  |   ..$ Pqr: chr "New Ab$Pqr"
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Tue, May 26, 2020 at 10:45 AM John Harrold <john.m.harrold using gmail.com>
> wrote:
>
>> Hello,
>>
>>
>> I'm testing some code in R 4.0, and I'm having an issue with the
>> following"
>>
>> # -------------
>> rm(list=ls())
>> graphics.off()
>> #load("/tmp/post.RData")
>> var = list();
>> # If I uncomment this it fixes things:
>> # var$options = list(mi   = list(),
>> #                    misc = list())
>> #
>> var$options$misc$abc = "123"
>> var$options$mi$something    = 13
>> #------------
>>
>> This is a stripped down example but it exhibits the issue I"m having.
>> Basically when I create the list element var$options$mi the contents of
>> var$options$misc move over to var$options$mi. And what was in
>> var$options$misc become NULL:
>>
>> So now var$options looks like:
>>
>> var$options
>> $misc
>> $misc$abc
>> NULL
>>
>> $mi
>> $mi$abc
>> [1] "123"
>> $mi$something
>> [1] 13
>>
>> This worked (still works) in R 3.5.1. I understand partial matching, but
>> is
>> this normal lists moving over to elements like this? I can uncomment the
>> text mentioned in the example and it seems to fix it, but I'm wondering if
>> this is a bug or just my poor programming coming back to bite me.
>>
>> I've included my sessionInfo() at the bottom.
>>
>> Thanks
>> John
>> :wq
>>
>>
>> sessionInfo()
>>
>> R version 4.0.0 (2020-04-24)
>>
>> Platform: x86_64-apple-darwin17.0 (64-bit)
>>
>> Running under: macOS Mojave 10.14.5
>>
>>
>> Matrix products: default
>>
>> BLAS:
>> /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
>>
>> LAPACK:
>>
>> /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
>>
>>
>> locale:
>>
>> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>>
>>
>> attached base packages:
>>
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>>
>> other attached packages:
>>
>> [1] gdata_2.18.0  ggplot2_3.3.0 deSolve_1.28
>>
>>
>> loaded via a namespace (and not attached):
>>
>>  [1] Rcpp_1.0.4.6     gtools_3.8.2     withr_2.2.0      assertthat_0.2.1
>>
>>  [5] dplyr_0.8.5      digest_0.6.25    crayon_1.3.4     grid_4.0.0
>>
>>  [9] R6_2.4.1         lifecycle_0.2.0  gtable_0.3.0     magrittr_1.5
>>
>> [13] scales_1.1.1     pillar_1.4.4     rlang_0.4.6      vctrs_0.3.0
>>
>> [17] ellipsis_0.3.1   glue_1.4.1       purrr_0.3.4      munsell_0.5.0
>>
>> [21] compiler_4.0.0   pkgconfig_2.0.3  colorspace_1.4-1 tidyselect_1.1.0
>>
>> [25] tibble_3.0.1
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

-- 
John
:wq

	[[alternative HTML version deleted]]



More information about the R-help mailing list