Re: [R] Unexpected result for df column $ subset with non-existent name

2022-10-30 Thread Andrew Simmons
partial match attr is for something like attr(data.frame(), "cla") which will partially match to "class". On Sun, Oct 30, 2022, 12:55 Joshua Ulrich wrote: > For what it's worth, I set these options to warn me about partial matches: > > options(warnPartialMatchArgs = TRUE, >

Re: [R] Unexpected result for df column $ subset with non-existent name

2022-10-30 Thread Joshua Ulrich
For what it's worth, I set these options to warn me about partial matches: options(warnPartialMatchArgs = TRUE, warnPartialMatchAttr = TRUE, warnPartialMatchDollar = TRUE) That warns about this particular case, as well as partial argument name matches in function calls. I don't

Re: [R] Unexpected result for df column $ subset with non-existent name

2022-10-28 Thread Rolf Turner
On Fri, 28 Oct 2022 16:42:41 +0100 Rui Barradas wrote: > This behavior, partial matching of column or list members names when > extracting with `$` is practically a FAQ. > See the latest R-Help thread on it after the release of R 4.0 > > >

Re: [R] Unexpected result for df column $ subset with non-existent name

2022-10-28 Thread Rui Barradas
Às 14:52 de 28/10/2022, Sergei Ko escreveu: Hi All, Just noticed that R returns results for non-existent name if you have another variable with the same beginning when you subset with $. See the code below: name_0 <- "ID" name_1 <- "name" name_2 <- "name1" v0 <- 1:200 v1 <- c(rep(0,100),

Re: [R] Unexpected result for df column $ subset with non-existent name

2022-10-28 Thread Bert Gunter
Does this explain it: (from ?Extract) name A literal character string or a name (possibly backtick quoted). For extraction, this is normally (see under ‘Environments’) **partially matched** to the names of the object. -- Bert On Fri, Oct 28, 2022 at 6:53 AM Sergei Ko wrote: > > Hi All, > >

[R] Unexpected result for df column $ subset with non-existent name

2022-10-28 Thread Sergei Ko
Hi All, Just noticed that R returns results for non-existent name if you have another variable with the same beginning when you subset with $. See the code below: name_0 <- "ID" name_1 <- "name" name_2 <- "name1" v0 <- 1:200 v1 <- c(rep(0,100), rep(1,100)) v2 <- c(rep(0,50), rep(1,150)) df <-