r - Converting from a Formula object to a list -


in r, iterate on formula object. r automatically converts formula parse tree, see no reason why shouldn't able iterate.

for example, f <- ~x + y has elements f[[1]] = ~ , f[[2]] = x + y. however, for(v in f) print(tostring(v)) not output

[1] "~" [1] "+, x, y" 

as expect to. instead, gives error invalid for() loop sequence.

if need manually, use for(i in 1:length(f)) print(tostring(f[[i]])) produce correct output. however, know why first method not work.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -