Skip to content

Bug with indexing in list #133

Description

@marcenavuc

Hello, I was developing an R course on jupyter notebook and found a bug related to indexing in list.

When I run this code in jupyter notebook

a <- list(1:4, eee=3, a = 5:6)
a[c(T, F, F)]

the output is like this

$NA =
1 2 3 4

When I run this code in r prompt or r studio, output is

[[1]]
[1] 1 2 3 4

My sessionInfo in jupyter notebook

R version 4.0.2 (2020-06-22)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS/LAPACK: /home/mark/anaconda3/envs/r-enviroment/lib/libopenblasp-r0.3.10.so

locale:
 [1] LC_CTYPE=ru_RU.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=ru_RU.UTF-8        LC_COLLATE=ru_RU.UTF-8    
 [5] LC_MONETARY=ru_RU.UTF-8    LC_MESSAGES=ru_RU.UTF-8   
 [7] LC_PAPER=ru_RU.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=ru_RU.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_4.0.2  ellipsis_0.3.1  IRdisplay_0.7.0 pbdZMQ_0.3-3   
 [5] tools_4.0.2     htmltools_0.5.0 pillar_1.4.6    base64enc_0.1-3
 [9] crayon_1.3.4    uuid_0.1-4      IRkernel_1.1.1  jsonlite_1.7.0 
[13] digest_0.6.25   lifecycle_0.2.0 repr_1.1.0      rlang_0.4.7    
[17] evaluate_0.14  

Activity

  1. flying-sheep commented on Aug 19, 2020

    @flying-sheep
    Member

    What a weird object. You can recreate it via:

    l <- list(1:4)
    names(l) <- ''

    Accessing its element via l[['']] or `$`(l, '') doesn’t work. It’s for all intents and purposes equal to list(1:4), except that identical(names(l), '').

  2. flying-sheep commented on Aug 19, 2020

    @flying-sheep
    Member

    Fixed by 9af4e98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions