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

Update data frame dereferencing to include partial matching? #4

Open
tdsmith opened this issue Apr 14, 2013 · 2 comments
Open

Update data frame dereferencing to include partial matching? #4

tdsmith opened this issue Apr 14, 2013 · 2 comments

Comments

@tdsmith
Copy link
Owner

tdsmith commented Apr 14, 2013

 * 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

@cubranic
Copy link

Use [[ for exact name matching.

@dwinsemius
Copy link

dwinsemius commented Oct 26, 2019

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.

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

No branches or pull requests

3 participants