{"action":"created","issue":{"url":"https://api.github.com/repos/IRkernel/IRdisplay/issues/18","repository_url":"https://api.github.com/repos/IRkernel/IRdisplay","labels_url":"https://api.github.com/repos/IRkernel/IRdisplay/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/IRkernel/IRdisplay/issues/18/comments","events_url":"https://api.github.com/repos/IRkernel/IRdisplay/issues/18/events","html_url":"https://github.com/IRkernel/IRdisplay/issues/18","id":142927990,"number":18,"title":"as.character(htmlwidget) gives error in the display system","user":{"login":"janschulz","id":890156,"avatar_url":"https://avatars.githubusercontent.com/u/890156?v=3","gravatar_id":"","url":"https://api.github.com/users/janschulz","html_url":"https://github.com/janschulz","followers_url":"https://api.github.com/users/janschulz/followers","following_url":"https://api.github.com/users/janschulz/following{/other_user}","gists_url":"https://api.github.com/users/janschulz/gists{/gist_id}","starred_url":"https://api.github.com/users/janschulz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janschulz/subscriptions","organizations_url":"https://api.github.com/users/janschulz/orgs","repos_url":"https://api.github.com/users/janschulz/repos","events_url":"https://api.github.com/users/janschulz/events{/privacy}","received_events_url":"https://api.github.com/users/janschulz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2016-03-23T10:57:02Z","updated_at":"2016-03-24T11:11:10Z","closed_at":null,"body":"```R\r\n#devtools::install_github(\"renkun-ken/formattable\")\r\ndf <- data.frame(\r\n  id = 1:10,\r\n  name = c(\"Bob\", \"Ashley\", \"James\", \"David\", \"Jenny\", \r\n    \"Hans\", \"Leo\", \"John\", \"Emily\", \"Lee\"), \r\n  age = c(28, 27, 30, 28, 29, 29, 27, 27, 31, 30),\r\n  grade = c(\"C\", \"A\", \"A\", \"C\", \"B\", \"B\", \"B\", \"A\", \"C\", \"C\"),\r\n  test1_score = c(8.9, 9.5, 9.6, 8.9, 9.1, 9.3, 9.3, 9.9, 8.5, 8.6),\r\n  test2_score = c(9.1, 9.1, 9.2, 9.1, 8.9, 8.5, 9.2, 9.3, 9.1, 8.8),\r\n  final_score = c(9, 9.3, 9.4, 9, 9, 8.9, 9.25, 9.6, 8.8, 8.7),\r\n  registered = c(TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE),\r\n  stringsAsFactors = FALSE)\r\nlibrary(formattable)\r\n\r\nf <- formattable(df, list(\r\n  age = color_tile(\"white\", \"orange\"),\r\n  grade = formatter(\"span\",\r\n    style = x ~ ifelse(x == \"A\", style(color = \"green\", font.weight = \"bold\"), NA)),\r\n  test1_score = normalize_bar(\"pink\", 0.2),\r\n  test2_score = normalize_bar(\"pink\", 0.2),\r\n  final_score = formatter(\"span\",\r\n    style = x ~ style(color = ifelse(rank(-x) <= 3, \"green\", \"gray\")),\r\n    x ~ sprintf(\"%.2f (rank: %02d)\", x, rank(-x))),\r\n  registered = formatter(\"span\", \r\n    style = x ~ style(color = ifelse(x, \"green\", \"red\")),\r\n    x ~ icontext(ifelse(x, \"ok\", \"remove\"), ifelse(x, \"Yes\", \"No\")))\r\n))\r\nw <- as.htmlwidget(f)\r\nh <- htmlwidgets:::toHTML(w, standalone = FALSE, knitrOptions = NULL)\r\nas.character(h)\r\n```\r\n\r\nResults in \r\n```\r\nError: is.vector(vec) || is.factor(vec) is not TRUE\r\nTraceback:\r\n\r\n1. tryCatch({\r\n .     for (mime in getOption(\"jupyter.display_mimetypes\")) {\r\n .         r <- mime2repr[[mime]](obj)\r\n .         if (!is.null(r)) \r\n .             data[[mime]] <- r\r\n .     }\r\n . }, error = handle_error)\r\n\r\n\"\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/IRkernel/IRdisplay/issues/comments/200791184","html_url":"https://github.com/IRkernel/IRdisplay/issues/18#issuecomment-200791184","issue_url":"https://api.github.com/repos/IRkernel/IRdisplay/issues/18","id":200791184,"user":{"login":"flying-sheep","id":291575,"avatar_url":"https://avatars.githubusercontent.com/u/291575?v=3","gravatar_id":"","url":"https://api.github.com/users/flying-sheep","html_url":"https://github.com/flying-sheep","followers_url":"https://api.github.com/users/flying-sheep/followers","following_url":"https://api.github.com/users/flying-sheep/following{/other_user}","gists_url":"https://api.github.com/users/flying-sheep/gists{/gist_id}","starred_url":"https://api.github.com/users/flying-sheep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flying-sheep/subscriptions","organizations_url":"https://api.github.com/users/flying-sheep/orgs","repos_url":"https://api.github.com/users/flying-sheep/repos","events_url":"https://api.github.com/users/flying-sheep/events{/privacy}","received_events_url":"https://api.github.com/users/flying-sheep/received_events","type":"User","site_admin":false},"created_at":"2016-03-24T11:11:10Z","updated_at":"2016-03-24T11:11:10Z","body":"> It's missing a space there\r\n\r\nfixed\r\n\r\n> reason for not including `repr_xxxx.vector`\r\n\r\nwho said we’d do that? and would it even do sth.? i thought you need to do `*.integer`, …?\r\n\r\n>  a \"STRING\" is also a vector and already needs special attention\r\n\r\nthere are no primitive/individual values in R, and we special case length-1 vectors so we don’t create e.g. HTML lists for individual values."}}