{"action":"created","issue":{"url":"https://api.github.com/repos/dmlc/xgboost/issues/1045","repository_url":"https://api.github.com/repos/dmlc/xgboost","labels_url":"https://api.github.com/repos/dmlc/xgboost/issues/1045/labels{/name}","comments_url":"https://api.github.com/repos/dmlc/xgboost/issues/1045/comments","events_url":"https://api.github.com/repos/dmlc/xgboost/issues/1045/events","html_url":"https://github.com/dmlc/xgboost/issues/1045","id":143541148,"number":1045,"title":"[R package] S4 and S3 class systems use","user":{"login":"khotilov","id":1613551,"avatar_url":"https://avatars.githubusercontent.com/u/1613551?v=3","gravatar_id":"","url":"https://api.github.com/users/khotilov","html_url":"https://github.com/khotilov","followers_url":"https://api.github.com/users/khotilov/followers","following_url":"https://api.github.com/users/khotilov/following{/other_user}","gists_url":"https://api.github.com/users/khotilov/gists{/gist_id}","starred_url":"https://api.github.com/users/khotilov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khotilov/subscriptions","organizations_url":"https://api.github.com/users/khotilov/orgs","repos_url":"https://api.github.com/users/khotilov/repos","events_url":"https://api.github.com/users/khotilov/events{/privacy}","received_events_url":"https://api.github.com/users/khotilov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-25T16:55:53Z","updated_at":"2016-04-04T06:42:31Z","closed_at":null,"body":"There seem to be some issues with how these R class systems are being used. The `xgb.DMatrix` and `xgb.Booster` are defined as virtual S4 classes. But the objects produced by `xgb.DMatrix()` and `xgb.Booster()` are in fact S3 objects, since they are not created with `new(...)` but with `structure(..., class='...')`. This leads to some awkward situations. E.g., non-primitive functions (e.g.,`nrow`) could be dispatched onto those objects using S4-style code (via some S3 byways, I guess), but the dispatch of primitive functions (e.g., `dim`) cannot be implemented S4-style.\r\n\r\nHere are some possible options:\r\n\r\n1. convert everything to S3 system (I think I would be able to do it fairly easily)\r\n1. implement proper use of S4 system by defining non-virtual classes and all the S4 shenanigans (but is there any real need for this more complex approach?)\r\n1. continue developing on the top of this mixture of S3 and rudimentary S4 (IMO, that would be a hack)\r\n\r\n@hetong007: were there any reasons behind the choice to use S4, like any plans for more complex class hierarchies or implementing some restrictions?"},"comment":{"url":"https://api.github.com/repos/dmlc/xgboost/issues/comments/205159063","html_url":"https://github.com/dmlc/xgboost/issues/1045#issuecomment-205159063","issue_url":"https://api.github.com/repos/dmlc/xgboost/issues/1045","id":205159063,"user":{"login":"khotilov","id":1613551,"avatar_url":"https://avatars.githubusercontent.com/u/1613551?v=3","gravatar_id":"","url":"https://api.github.com/users/khotilov","html_url":"https://github.com/khotilov","followers_url":"https://api.github.com/users/khotilov/followers","following_url":"https://api.github.com/users/khotilov/following{/other_user}","gists_url":"https://api.github.com/users/khotilov/gists{/gist_id}","starred_url":"https://api.github.com/users/khotilov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khotilov/subscriptions","organizations_url":"https://api.github.com/users/khotilov/orgs","repos_url":"https://api.github.com/users/khotilov/repos","events_url":"https://api.github.com/users/khotilov/events{/privacy}","received_events_url":"https://api.github.com/users/khotilov/received_events","type":"User","site_admin":false},"created_at":"2016-04-04T06:42:31Z","updated_at":"2016-04-04T06:42:31Z","body":"Closed by #1050 "}}