Base64 encoding a .Rda file



I'm trying to figure out how to put a .Rda file into Base64 encoding for it to be shipped to and from an API. I am really struggling with how to do this. Here's what I've got, but I think it's way off target:

cuse <- read.table("http://data.princeton.edu/wws509/datasets/cuse.dat", header=TRUE) lrfit <- glm( cbind(using, notUsing) ~ age + education + wantsMore , family = binomial, data=cuse) filename <- "C:/test.Rda" save(lrfit, file=filename) library("base64enc") tst <- base64encode(filename) save(tst, file="C:/encode.Rda") base64decode(file="C:/encode.Rda", output = "C:/decode.Rda")

When I try to open the decode.Rda file, it throws a magic number error. Like I said, I think I'm way off base here, and any help would be appreciated. Thank you so much.


Here a correct sequence of steps that should allow for the correct encoding/decoding

#sample data dd<-iris fn <- "test.rda" fnb4 <- "test.rdab64" #save rda save(iris, file=fn) #write base64 encoded version library(base64enc) txt<-base64encode(fn) ff<-file(fnb4, "wb") writeBin(txt, ff) close(ff) #decode base64 encoded version base64decode(file=fnb4, output = "decode.rda") (load("decode.rda")) # [1] "iris"

The problem was your second save(). That was creating another RDA file with the base64 data encoded inside. It was not writing a base64 encoded version of the RDA file to disc.


  • Offer foreground download to user with possible dialog
  • Ordering factors in number order for ggplot
  • Different ways of zooming in OpenGL
  • Extract Residual Deviance from anova (glm) in R
  • Statsmodels Poisson glm different than R
  • Learning about game development, any books recommended? [closed]
  • How to access span using beautifulSoup?
  • How to solve Bad Request (#400) Unable to verify your data submission in yii2?
  • Bootstrap - Scrollspy scrolling skipping second to last section
  • plot phylogenetic logistic regression with binary response variable
  • Creating a dataframe from an lapply function with different numbers of rows
  • App Script HtmlService use with font like Google Web Fonts?
  • ingenious idea needed: how to declare different sizes for different fonts? @font-face?
  • Jsoup - How to extract every elements
  • Android signing problem
  • Can you use the lapply() function to alter the value of input?
  • How to capture a string between two tags
  • Intellisense cannot infer type from extention method
  • what can i do if for loop repeat single row from mysql database?
  • How to plot a ROC curve from Classification Tree probabilities
  • Understanding how to construct GHC.Generics Rep's and convert back to values
  • CSS Local Font not showing up
  • Meteor throws throwIfSelectorIsNotId exception
  • Fade Background but NOT Text
  • Importing CSS is ending up with an error
  • Calculating subtotals in R
  • Extract text from “” HTML tag
  • Docker container for google cloudML on compute engine - authenticating for mounting bucket
  • how to post with curl to REST/JSON service?
  • Max of several columns
  • How to use arithmetic operators with SAS macro variables [duplicate]
  • Netlink sockets and libnl - nl_recvmsgs_default returning -16 (EBUSY)
  • saving file generated by TCPDF
  • How to view images from protected folder with php?
  • Textfile Structure (tables)
  • vba code to select only visible cells in specific column except heading
  • sending mail using smtp is too slow
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?