workspace cannot be loaded in server, file has magic number 'RDX3' - r

I've been looking through other SO posts and I've seen that people had a similar problem to mine before. However, in my case when I load my RData workspace in RStudio it works just fine. However, when I try to load it in the server I get the following error:
Error in load(file = "/home/ubuntu/myfile.RData") :
bad restore file magic number (file may be corrupted) -- no data loaded
In addition: Warning message:
file ‘myfile.RData’ has magic number 'RDX3'
Use of save versions prior to 2 is deprecated
I've loaded similar RData files in the server before and it always worked fine. The same file is loaded without any problems in RStudio as I said, but somehow the server doesn't like it

Did you update R in your computer recently? If you did, from R 3.5.0, RData are saved using version 3 by default (RDX3). If you have an earlier version of R in your server, you probably need to save your data using the right version for your server (updating R in your server is another option). Please check the option version in the help of the save command to learn how to do that.

Related

Error message "Error: openxlsx can only read .xlsx or .xlsm files" in R 4.1.3

I have a script I was using a few months ago, and I was asked to re-output it using new source data. Now I get the message "Error: openxlsx can only read .xlsx or .xlsm files."
Of course, it IS an .xlsx file.
Not only that, I went back and ran the same script on the old source file (which worked), and...I get the same error!! I haven't changed any code, but my version of R has been updated by the administrators from 3.6 to 4.1.3 (I work in a virtual environment). I have confirmed that openxlsx version 4.2.5 is installed.
I've seen in other posts that people recommend using other packages to read xlsx files. That is not an ideal option here for administrative reasons (getting permission to install new packages can be very time-consuming and may blow deadlines), and I've started pursuing that option, but in the meantime, does anyone have any ideas?
Unfortunately, changing the format (i.e. exporting as csv and using read.csv) is also not an option, because we're auditors and doing that will break the audit trail.
OK, a colleague of mine solved the problem.
The source file has the extension ".XLSX". In order for openxlsx to read the file, you have to change the extension IN THE CODE to ".xlsx" (in my case at least, I didn't even have to change the actual extension of the file--just the quoted reference in the code), although other colleagues say they have had to do this.

RStudio states file does not exist

Attempting to use the mread function to open a cpp file through R. However, when I run the script I get the following:
setwd("C:/Users/Gustavo/Documents/R/page-2018-mrgsolve-master/model")
getwd()
#> [1] "C:/Users/Gustavo/Documents/R/page-2018-mrgsolve-master/model"
library(mrgsolve)
mod <- mread("simple", "model")
#> Error: project directory 'model' must exist and be readable.
Obviously I am setting the directory to "model" itself. So why isn't R able to read it? Any help would be appreciated as I am still learning R and want to learn the mrgsolve package as well.
Additional info: R version 3.4.4. Rtools version 3.4.0. Rstudio version 1.1.463.
An adaptation to the email I sent my colleagues that were assisting me with a similar issue:
To review, I was unable to open any files through RStudio because RStudio returned error messages indicating either that the file itself or the work directory did not exist. I've done multiple installations of different versions of R, RStudio, and Rtools in an attempt to resolve the issue. I also moved the locations of files and programs of interest and changed the work directory to see if that made a difference. Unfortunately, when RStudio is first initiated on a computer, it establishes a "hidden directory" folder that retains the settings of the program when it was first initiated. However, by deleting this folder, RStudio was wiped and I was able to regain control of where files would be stored and read as desired (more on this in the following link: https://support.rstudio.com/hc/en-us/articles/200534577-Resetting-RStudio-Desktop-s-State). A combination of this and forcing Rtools to the front of the 'path' also allowed me to resolve 'status 127' errors that I was receiving as well.
Unfortunately, this is the result of a more personal issue between the initial settings that RStudio took to my computer and my attempt to manipulate where RStudio should read files which I guess were discordant of one another? Regardless, it seems that I would need to be more cognizant of how RStudio establishes a folder which retains its initial settings.

R: Use of save versions prior to 2 is deprecated with a RDA file [duplicate]

I've been looking through other SO posts and I've seen that people had a similar problem to mine before. However, in my case when I load my RData workspace in RStudio it works just fine. However, when I try to load it in the server I get the following error:
Error in load(file = "/home/ubuntu/myfile.RData") :
bad restore file magic number (file may be corrupted) -- no data loaded
In addition: Warning message:
file ‘myfile.RData’ has magic number 'RDX3'
Use of save versions prior to 2 is deprecated
I've loaded similar RData files in the server before and it always worked fine. The same file is loaded without any problems in RStudio as I said, but somehow the server doesn't like it
Did you update R in your computer recently? If you did, from R 3.5.0, RData are saved using version 3 by default (RDX3). If you have an earlier version of R in your server, you probably need to save your data using the right version for your server (updating R in your server is another option). Please check the option version in the help of the save command to learn how to do that.

RStudio Working Directory Error

Updated question with more details:
I am not able to open my R workspace, and getting the following error (in base R, RStudio simply shows the first line of error and then freezes):
Error: value of 'SET_ATTRIB' must be a pairlist or NULL, not a 'list'
During startup - Warning message:
unable to restore saved data in C:\R_Library\A\.RData
Other R Workspaces are loading so definitely it is a corrupt .RData file issue. The R Workspace is half a GB in size. I am working on a Windows machine (64-bit) with R version 3.1.2.
My R was running slow, and I decided to save my Workspace and relaod the image. That's when the error message started. It could be due to large data in the environment, but I have handled more data before without any issues.
There is no information available on how to fix this issue. I have some unsaved code in the directory, which is the bare minimum I would want to recover. Any advice will be useful.
Try renaming the file .RData in your R working directory. Start R, and run
load("whatever you renamed .RData to").
If this still does not work, try clicking on your renamed R project file. It should open your workspace with an empty environment.

When loading data in Rstudio getting error "ReadItem: unknown type 161, perhaps written by later version of R"?

When I am trying to load a clean data in Rstudio, file name called salesClean.RData, I am getting error.
Error message is: ReadItem: unknown type 161, perhaps written by later version of R
Screenshot of error message:
Here is what worked for me:
Simple Solution:
Try to use the tool Load Workspace. It allows you to select the Rds file and load it into memory.
Best Solution:
In some cases you do need to load the file programatically. In these situations you will probably prefer get your R up to date. You can do this by running the code:
install.packages("installr")
require(installr)
updateR()
Also, you can update your installed packages in RStudio on Tools > Check for packages updates.
Make sure that you're using the latest version not only of Rstudio, but R as well. Try sessionInfo() command, it should say that you have R version 3.1.2.
In my case, finally I found it's because the hard disk under my root is full. I freed some disk memory and re-saved the .RDdata file, the load works again.
For me, had a very similar experience to #CcMango, though for me it was because I had run out of session memory. I restarted my Rstudio session with fresh memory and loaded fewer files and that solved it. For similar issues, I've had luck rewriting in batches or querying from other sources too.

Resources