Not automatically downloading dropbox files when opening data in R - r

I recently bought a new Macbook pro (M1) and am trying to run R codes.
I open and run a R script that I have been working, but data such as csv, excel files, and RData in the dropbox are not loaded. It works only after I manually download the files in Finder, otherwise files are not automatically downloaded when trying to load in R.
Here is an example of the code and the error message
setwd('/Users/xxx/Dropbox/Data')
load('dta.RData')
Error in load("dta.RData") :
empty (zero-byte) input file
If I manually download the "dta.Rata" in finder (using Make Available Offline) and run the same code it works well.
Any solution?

I found that this
https://help.dropbox.com/installs-integrations/desktop/macos-12-monterey-support
I guess we should wait until Dropbox find the solution.

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.

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

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.

Programmatically load file into Rstudio

I'm developing R code whose output is an R script, is it possible to automatically load the generated file in a RStudio tab?
So far I've checked the rstudioapi, but I don't find any suitable function.
I've already tried:
file.show(stringr::str_c(name,".r"))
but file.show open the file using an external editor.
You can use source("path/to/script.R") to run an R script, and load all the data/variables into the global R environment
In order to just open the file in RStudio, without running it, you can use rstudioapi::navigateToFile("path/to/file.R")

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.

R script to check if my zip folder is corrupt

There is a python testzip() module to check if a zip file is corrupt in python. However i want to know it's parallel in R as well.
How to check if a zip folder is corrupt by writing a small script in R ?

Resources