I don't see how or why you want to do this, but it's a fun idea If I get it correctly, you want to store a dataframe in a QR code and then be able to retrieve it when scanned right?
This is my approach:
library("stringr")
library("qrencoder")
library("datapasta")
#Take a dataframe
myDataframe = data.frame(replicate(2,sample(0:50,24,rep=TRUE)))
#Generate the full dataframe as text using datapasta
#and remove white spaces and next line characters
myDataFrame = str_remove_all(
df_construct(myDataframe),
"\\\n|\\s")
#Plot the data as a QR code
image(qrencode_raster(myDataFrame),
asp=1, col=c("white", "black"), axes=FALSE,
xlab="", ylab="")
Note that QR codes have a limited amount of characters they can encode, so this will only work for relatively small data frames...
Also, in this code I removed all spaces from the data frame to conserve space in the QR code given all data was numeric. If the data contained strings, spaces between words would be removed with this code as well, so you should alter that if needed.