richfitz / remoji

Emoji for R :joy_cat:
Other
42 stars 4 forks source link

emoji_matrix() for tabular displaying (to check what's supported) #7

Open HenrikBengtsson opened 8 years ago

HenrikBengtsson commented 8 years ago

Toyed around over a coffee after seeing https://twitter.com/GaborCsardi/status/752891827800473604 and came up with the following one:

emoji_matrix <- function(x = emoji(list_emoji()), byrow = TRUE, ncol = 20, empty = "", quote = FALSE, rownames = NULL, colnames = NULL) {
  n <- length(x)
  nrow <- ceiling(n / ncol)

  ## Pad with empty?
  if (n < nrow * ncol) {
    x <- c(x, rep(empty, times = nrow * ncol - n))
  }

  if (is.null(colnames)) colnames <- seq_len(ncol)
  if (is.null(rownames)) {
      starts <- seq(from=0L, to=nrow-1L) * ncol
      ends <- starts + ncol
      ends[length(ends)] <- n
      rownames <- sprintf("%03d:%03d", starts+1L, ends)
  }

  dimnames <- list(rownames, colnames)
  y <- matrix(x, byrow = byrow, nrow = nrow, ncol = ncol, dimnames = dimnames)

  nrow <- nrow(y)
  ncol <- ncol(y)

  if (!quote) y <- noquote(y)

  y
}

In the Terminal of Ubuntu 16.04, it'll display the following: emoji_matrix

gaborcsardi commented 8 years ago

👍 💯

HenrikBengtsson commented 8 years ago

Much less exciting in Ubuntu 16.04 xterm (maybe there's a configuration that fixes this?): emoji_matrix xterm

gaborcsardi commented 8 years ago

Hmmmm. Btw. installing extra fonts is also a possibility. Or just depending on https://github.com/GuangchuangYu/emojifont and installing that somehow to the terminal. If that's possible.

But I guess we can also start simple, and only support terminal types and are known to work.

gaborcsardi commented 8 years ago

Btw. there is also hope for windows: http://disq.us/p/12l26rr

But initially we can just turn it off on windows....

richfitz commented 8 years ago

Hmm, on Mint in the terminal I get

screenshot_2016-07-13_09-09-49

so I may not have set emoji up here properly.

gaborcsardi commented 8 years ago

😭