0

I am uploading a file image (RData) to git-hub.

When the file image is generated thus:

save.image("myfile.RData",compress = FALSE, version = 3)

I have no issue loading it back into R.

However, if I put the same file image into git-hub and try to download and load it I get an error message

githubURL <- "https://github.com/mygit/folde/myfile.RData"
download.file(githubURL, destfile = "myfile.RData", method="curl")
read("myfile.RData")

Error in load("myfile.RData") : 
  bad restore file magic number (file may be corrupted) -- no data loaded
In addition: Warning message:
file ‘ myfile.RData’ has magic number 'Not F'
  Use of save versions prior to 2 is deprecated 

torek
  • 448,244
  • 59
  • 642
  • 775
MCS
  • 1,071
  • 9
  • 23
  • 1
    You probably should use the `rawdata` url? `https://github.com/mygit/folde/myfile.RData` doesn't look right – evolutionxbox Oct 05 '21 at 15:42
  • 1
    would that be "https://raw.github.com/mygit/folder/myfile.RData" "https://raw.github.com/mygit/folder/myfile.RData?raw=true" or the permalink? – MCS Oct 05 '21 at 15:49
  • 1
    e.g. https://raw.githubusercontent.com/Rush/Font-Awesome-SVG-PNG/master/black/png/128/500px.png is the raw version of https://github.com/Rush/Font-Awesome-SVG-PNG/blob/master/black/png/128/500px.png – evolutionxbox Oct 05 '21 at 15:51
  • Note that GitHub is not Git. GitHub *use* Git, for sure; but they use a lot of other things too (issues databases for instance), and they aren't those things either. If you want to bypass Git and store and load files directly on GitHub, you'll need to find methods that avoid making changes *to* those files. If you choose to store and load through *Git*, using Git locally, just make sure to tell Git to treat binary files as binary. – torek Oct 05 '21 at 22:37
  • 1
    As it is, you're using GitHub, and using it through interfaces that muck about with your files. So you're mis-using GitHub. The `raw` URLs that @evolutionxbox mentioned work well for reading data; I'm not sure what if anything works for sending it. – torek Oct 05 '21 at 22:39

1 Answers1

0

It's possible that your issue come from git and an conversion of the end-of-line markers.

check your config, it must return false

git config --get core.autocrlf
Matth B
  • 64
  • 1
  • 4