Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug - Lists within a list having the same name are shown to have the same content. Reproduction violates best practice. #2966

Open
1morestudent opened this issue Jun 9, 2018 · 6 comments

Comments

@1morestudent
Copy link

@1morestudent 1morestudent commented Jun 9, 2018

System details

RStudio Edition : Desktop
RStudio Version : 1.1.383
OS Version      : Ubuntu 17.10 x64
R Version       :  R version 3.4.2 (2017-09-28)

Steps to reproduce the problem

list1 <- list(c(1, 1, 1))
list2 <- list(c(2, 2 ,2))
a     <- list(list1, list2)
names(a) <- c("the_same", "the_same")

Clicking on the generated list in the global environment, so that the content of the list is displayed in the upper left window.

The window shows the content of both lists to be the same, although they are not, as can be checked with a[[1]][[1]] == a[[2]][[1]]

Describe the problem in detail

When displaying lists within lists, RStudio displays the same content for lists with the same name, even if the real content is different. This does not seem to happen with simple lists:

item1 <- c(1,1,1)
item2 <- c(2,2,2)
a <- list(item1, item2)

Describe the behavior you expected

To reproduce this bug you need to violate best practice. R seems, however, able to handle this, so I expect RStudio to work in the same way or produce a warning of some kind.
This is a really minor problem and should not happen for anyone coding in a reasonable manner. I still wanted to report this, as the behavior of RStudio deviates from the behavior of R itself.

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Jun 9, 2018

The problem here is that the Object Explorer attempts to index the object by name, and since names are duplicated the first entry with that name is selected (c(1, 1, 1)).

@dfalty
Copy link

@dfalty dfalty commented Jun 19, 2018

Reproduced on 1.2.747.

@kevinushey kevinushey added this to the v1.3 milestone May 21, 2019
@jmcphers jmcphers removed this from the v1.3 milestone Dec 2, 2019
@oganm
Copy link

@oganm oganm commented Feb 27, 2020

This is a really minor problem and should not happen for anyone coding in a reasonable manner. I still wanted to report this, as the behavior of RStudio deviates from the behavior of R itself.

If one tries to view an xml/html object, there naturally would be lots of elements with the same names due to tags being converted into names. listviewer package also fails with such objects so it does cause inconvenience when working with such files.

@jarekkupisz
Copy link

@jarekkupisz jarekkupisz commented Jul 3, 2020

I believe I encountered the same problem, however, it got me during interactive work with pipes.

library(magrittr)
list(a = 1) %>% View()

image

Then, without closing the pane:
list(a = 1, b = 2) %>% View()
image

When working with pipes and View() you'll keep seeing the first object you piped. The data/data.frame view pane does not suffer from this problem and always replaces the old object with a new one.

I'm on Windows 10 Rstudio 1.3.959 official channel.

@jmcphers
Copy link
Member

@jmcphers jmcphers commented Nov 4, 2020

Also reported by @dmurdoch in #8283.

@mikebessuille mikebessuille added this to the v1.5 milestone Nov 9, 2020
@mikebessuille
Copy link
Contributor

@mikebessuille mikebessuille commented Nov 9, 2020

Putting this in 1.5 since several people have discovered this.

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

No branches or pull requests

7 participants