dataframe - Data.frames in R: name autocompletion? -


sorry if trivial. seeing following behaviour in r:

> mydf <- data.frame(score=5, scorescaled=1) > mydf$score ## forgot score variable capitalized [1] 1 

expected result: returns null (even better: throws error).

i have searched this, unable find discussion of behaviour. able provide references on this, rationale on why done , if there way prevent this? in general love version of r little stricter variables, seems never happen...

the $ operator needs first unique part of data frame name index it. example:

> d <- data.frame(score=1, scotch=2) > d$sco null > d$scor [1] 1 

a way of avoiding behavior use [[]] operator, behave so:

> d <- data.frame(score=1, scotch=2) > d[['scor']] null > d[['score']] [1] 1 

i hope helpful.

cheers!


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -