I have a file wtf.r
containing the following code
test <- c(1:5)
abc <- c(1:5)
df <- data.frame(test, abc)
df$te
This returns [1] 1 2 3 4 5
both interactively in RStudio and by running rscript C:/Users/xx/Documents/wtf.r
, so it is not a problem with RStudio but rather with R.
Note that using df <- data.frame(test, abc) %>% as_tibble
fixes the problem:
> df$te
NULL
Warning message:
Unknown or uninitialised column: `te`.
And that this bug only exists when the column name can be autocompleted unabiguously. for example:
> test <- c(1:5)
> test2 <- c(1:5)
> df <- data.frame(test, test2)
> df$te
NULL
Version info
> version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
crt ucrt
system x86_64, mingw32
status
major 4
minor 2.1
year 2022
month 06
day 23
svn rev 82513
language R
version.string R version 4.2.1 (2022-06-23 ucrt)
nickname Funny-Looking Kid
I am interested in any comments shedding some light on the root cause of this behaviour.