I can't get RStudio to open my script with the correct encoding. I only see gibberish regardless of which encoding I choose. I have also tried to open it in R but that doesn't work either. I really need to open this script! Any ideas?
I have tried opening it in the texteditor, notepad and Word on my Mac. It is an .R file.
I have analyzed the file using the file -I command:
Stefans-MacBook-Pro:downloads stefan.e.oberg$ file -I TwinIVSimulationResults_new.R
TwinIVSimulationResults_new.R: application/x-gzip; charset=binary
What is your file extension ? Can you send your file ?
Have you tried to open it in an editor like notepad++ to see what is the encoding and if it works ?
Without more information, it will be difficult to help you.
I am sorry, I want to believe you, but this does not seem to be an R file, or even a textfile
# Download the file
url <- "https://gubox.box.com/shared/static/4k011vrk5381hkmmadb9dfbyc1x20c98.r"
script <- tempfile()
download.file(url, script, mode = "wb")
# Let's what is inside
readLines(script, n = 5)
#> Warning in readLines(script, n = 5): la ligne 3 contient un caractère nul
#> Warning in readLines(script, n = 5): la ligne 5 contient un caractère nul
#> [1] "RDX2"
#> [2] "X"
#> [3] ""
#> [4] "“¼d?á\177¦ÚJžþ?á^"
#> [5] "”&Ö›?án(¦žJ?áwt\030\033ª=?á~7Ãïì.?áo8Õèì!?á]5\021žã?á4'Ð9TÍ?á¦äªa×}?áHY\v!d-?ákÇ\022{é\027?á’"
# I can confirm it is not readable in notepad++ either.
# Does not seems to be an R script, or even a text file.
# Can we try guessing the MIME TYPE
library(simplemagic)
get_content_type(script)
#> [1] "???"
# No we can't...
unlink(script)
BIG thanks to everyone for trying and for your suggestions!!
Unzipping it didn't help. I saw a flash of the contents the first time I opened it in RStudio the other day before it all turned to gibberish. I guess that was the last I saw of it...
But, I have managed to recreate most of it from backups and hope I didn't miss anything too important. It is a simulation I use for the results in a chapter in a book. The book has been in production for 13 months and it was when I opened it for the last checks before publishing it that this happened...
Thank you all so much anyway!
Given the magic string RDX2, this is likely a saved R object of some form. You might try loading it with load() or readRDS() to recover whatever R objects are serialized within.
It's worth reiterating that this appears to be an R object, not an R script, hence why it looks like a binary mess when you open it within an editor.