{"action":"created","issue":{"url":"https://api.github.com/repos/wch/R6/issues/83","repository_url":"https://api.github.com/repos/wch/R6","labels_url":"https://api.github.com/repos/wch/R6/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/wch/R6/issues/83/comments","events_url":"https://api.github.com/repos/wch/R6/issues/83/events","html_url":"https://github.com/wch/R6/issues/83","id":136730912,"number":83,"title":"do.call for class methods","user":{"login":"terrytangyuan","id":4269898,"avatar_url":"https://avatars.githubusercontent.com/u/4269898?v=3","gravatar_id":"","url":"https://api.github.com/users/terrytangyuan","html_url":"https://github.com/terrytangyuan","followers_url":"https://api.github.com/users/terrytangyuan/followers","following_url":"https://api.github.com/users/terrytangyuan/following{/other_user}","gists_url":"https://api.github.com/users/terrytangyuan/gists{/gist_id}","starred_url":"https://api.github.com/users/terrytangyuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terrytangyuan/subscriptions","organizations_url":"https://api.github.com/users/terrytangyuan/orgs","repos_url":"https://api.github.com/users/terrytangyuan/repos","events_url":"https://api.github.com/users/terrytangyuan/events{/privacy}","received_events_url":"https://api.github.com/users/terrytangyuan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-26T15:43:46Z","updated_at":"2016-02-26T15:53:40Z","closed_at":"2016-02-26T15:45:41Z","body":"For example, I have a `Class1$addKV(\"key1\", \"value1\")` function. Is there a way to use `do.call()` to call it since I want to make this more general. \r\n\r\nThanks! "},"comment":{"url":"https://api.github.com/repos/wch/R6/issues/comments/189335993","html_url":"https://github.com/wch/R6/issues/83#issuecomment-189335993","issue_url":"https://api.github.com/repos/wch/R6/issues/83","id":189335993,"user":{"login":"wch","id":86978,"avatar_url":"https://avatars.githubusercontent.com/u/86978?v=3","gravatar_id":"","url":"https://api.github.com/users/wch","html_url":"https://github.com/wch","followers_url":"https://api.github.com/users/wch/followers","following_url":"https://api.github.com/users/wch/following{/other_user}","gists_url":"https://api.github.com/users/wch/gists{/gist_id}","starred_url":"https://api.github.com/users/wch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wch/subscriptions","organizations_url":"https://api.github.com/users/wch/orgs","repos_url":"https://api.github.com/users/wch/repos","events_url":"https://api.github.com/users/wch/events{/privacy}","received_events_url":"https://api.github.com/users/wch/received_events","type":"User","site_admin":false},"created_at":"2016-02-26T15:53:40Z","updated_at":"2016-02-26T15:53:40Z","body":"It depends on which part you want to be a string. If it's the object:\r\n\r\n```R\r\nobjName <- \"AnyClassName\"\r\n\r\nobj <- get(objName)\r\ndo.call(obj$addKV, list(\"key\", \"value\"))\r\n```\r\n\r\nIf it's the method:\r\n\r\n```R\r\nmethodName <- \"addKV\"\r\n\r\ndo.call(obj[[methodName]], list(\"key\", \"value\"))\r\n```\r\n\r\nIf you want to use a single string for both, you could use `eval`, although it's a little gross:\r\n\r\n```R\r\nf <- eval(\"AnyClassName$addKV\")\r\ndo.call(f, list(\"key\", \"value\"))\r\n```"}}