aRrgh
aRrgh copied to clipboard
Update data frame dereferencing to include partial matching?
* If you squint, `$` acts kind of like the `.` scope operator in C-like languages, at least for data frames. If you'd write `struct.instance_variable` in C, you'd maybe write `frame$column.variable` in R. But be careful - `$` tries to do partial matching of names if you supply a name it cannot find, but returns `NULL` if multiple elements match. Eg: `x <- data.frame(var1="a", var123="b"); x$var12` will return `var123`. Somewhat thankfully, `x$var1` will still return `var1`.
from cdrv
Use [[
for exact name matching.
I suppose you could suggest reading the extensive ?'['
page once or twice. I probably read it 10 or 20 times over the course of 10 years of R programming. I learned something new each time.