{"action":"created","issue":{"url":"https://api.github.com/repos/kbenoit/quanteda/issues/113","repository_url":"https://api.github.com/repos/kbenoit/quanteda","labels_url":"https://api.github.com/repos/kbenoit/quanteda/issues/113/labels{/name}","comments_url":"https://api.github.com/repos/kbenoit/quanteda/issues/113/comments","events_url":"https://api.github.com/repos/kbenoit/quanteda/issues/113/events","html_url":"https://github.com/kbenoit/quanteda/issues/113","id":141646100,"number":113,"title":"cannot build dfm in knitr (Rmarkdown)","user":{"login":"haodong","id":8103074,"avatar_url":"https://avatars.githubusercontent.com/u/8103074?v=3","gravatar_id":"","url":"https://api.github.com/users/haodong","html_url":"https://github.com/haodong","followers_url":"https://api.github.com/users/haodong/followers","following_url":"https://api.github.com/users/haodong/following{/other_user}","gists_url":"https://api.github.com/users/haodong/gists{/gist_id}","starred_url":"https://api.github.com/users/haodong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haodong/subscriptions","organizations_url":"https://api.github.com/users/haodong/orgs","repos_url":"https://api.github.com/users/haodong/repos","events_url":"https://api.github.com/users/haodong/events{/privacy}","received_events_url":"https://api.github.com/users/haodong/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-17T17:09:43Z","updated_at":"2016-03-18T10:01:13Z","closed_at":"2016-03-18T10:01:13Z","body":"```R\r\nc1 <- corpus(t1)\r\nc2 <- corpus(t2)\r\nsampleCorpus <- c1+c2\r\nwf <- dfm(sampleCorpus)\r\nwf <- dfm(ngrams(sampleCorpus))\r\n```\r\nI use such a standard command but being left errors when building R report by [knitr](https://github.com/yihui/knitr):\r\n```R\r\nQuitting from lines 68-69 (deReport.Rmd) \r\nError in UseMethod(\"features\") : \r\n  no applicable method for 'features' applied to an object of class \"dfmSparse\"\r\nCalls: <Anonymous> ... dfm.character -> dfm -> dfm.tokenizedTexts -> features\r\nExecution halted\r\nError: Failed to compile ....Rmd\r\n\r\nQuitting from lines 68-69 (deReport.Rmd) \r\nError in UseMethod(\"ngrams\") : \r\n  no applicable method for 'ngrams' applied to an object of class \"c('corpus', 'list')\"\r\nCalls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> dfm -> ngrams\r\nExecution halted\r\nError: Failed to compile ....Rmd\r\n```"},"comment":{"url":"https://api.github.com/repos/kbenoit/quanteda/issues/comments/198287641","html_url":"https://github.com/kbenoit/quanteda/issues/113#issuecomment-198287641","issue_url":"https://api.github.com/repos/kbenoit/quanteda/issues/113","id":198287641,"user":{"login":"kbenoit","id":2182246,"avatar_url":"https://avatars.githubusercontent.com/u/2182246?v=3","gravatar_id":"","url":"https://api.github.com/users/kbenoit","html_url":"https://github.com/kbenoit","followers_url":"https://api.github.com/users/kbenoit/followers","following_url":"https://api.github.com/users/kbenoit/following{/other_user}","gists_url":"https://api.github.com/users/kbenoit/gists{/gist_id}","starred_url":"https://api.github.com/users/kbenoit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbenoit/subscriptions","organizations_url":"https://api.github.com/users/kbenoit/orgs","repos_url":"https://api.github.com/users/kbenoit/repos","events_url":"https://api.github.com/users/kbenoit/events{/privacy}","received_events_url":"https://api.github.com/users/kbenoit/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T10:01:13Z","updated_at":"2016-03-18T10:01:13Z","body":"`ngrams()` does not work on a corpus, only on character objects or tokenised texts.  \r\n\r\n    > methods(ngrams)\r\n    [1] ngrams.character*      ngrams.tokenizedTexts*\r\n\r\nSo either extract the texts using `ngrams(texts(yourCorpus))` or tokenise it first. Note also that `tokenize()` can perform ngram tokenisation.  see `?tokenize()`.\r\n"}}