How to generate a QR code including a dataframe?

Hi all,
I have a dataframe that includes two colums and 24 rows of data as follows, for instance:


and I'd like to generate a QR code incorporating such dataframe, is it possible?
I would greatly appreciate any help!


I don't see how or why you want to do this, but it's a fun idea :slight_smile: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:


#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(

#Plot the data as a QR code
     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.

Hope this helps,


Thank you very much! It entirely solved my problem!

If you’re able to share, I am intensely curious :grin:: what is your application for a QR-encoded data frame?

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.