ggplot2 version of qrcode generator

library(qrcode)
library(tidyverse)
## ── Attaching packages ───────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.1.0     ✔ purrr   0.2.5
## ✔ tibble  1.4.2     ✔ dplyr   0.7.7
## ✔ tidyr   0.8.2     ✔ stringr 1.3.1
## ✔ readr   1.1.1     ✔ forcats 0.3.0
## ── Conflicts ──────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
#QRmatrix<-qrcode_gen('www.r-project.org',dataOutput=TRUE)
ggqrcode <- function(text, color="black", alpha=1) {
    pkg <- "qrcode"
    require(pkg, character.only = TRUE)
    x <- qrcode_gen(text, plotQRcode=F, dataOutput=T)
    x <- as.data.frame(x)

    y <- x
    y$id <- rownames(y)
    y <- gather(y, "key", "value", colnames(y)[-ncol(y)])
    y$key = factor(y$key, levels=rev(colnames(x)))
    y$id = factor(y$id, levels=rev(rownames(x)))

    ggplot(y, aes_(x=~id, y=~key)) + geom_tile(aes_(fill=~value), alpha=alpha) +
        scale_fill_gradient(low="white", high=color) +
        theme_void() + theme(legend.position='none')
} # https://github.com/GuangchuangYu/yyplot/blob/master/R/ggqrcode.R
p<-ggqrcode("Col_shade_rep3")
p

p2<-p + labs(title="Col shade rep3")
p2

# How to print out QRcodes on a label sheet?

library(cowplot) # see alternative in https://cran.r-project.org/web/packages/egg/vignettes/Ecosystem.html
## 
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggplot2':
## 
##     ggsave
# read sample data

# create QR code and store them in list object (using loop or sapply?)

# plot in one page with appropriate position in labels by cowplot

# save the plot in pdf file

# print the pdf on a label sheet!