How to fix Error in setwd("D:/") when opening R - r

I'm currently trying to Knit a file with RStudio and keep running into the below error:
Error in setwd("D:/") : cannot change working directory
Execution halted
However, when I check getwd() I get "/Users/my-name" as the working directory. I have also tried setwd("~/") and receive the same error in Markdown. Further, when I initially open RStudio I get
Error in setwd("D:/") : cannot change working directory
which suggests that there is an issue when I start R. Is there a way to get this error to stop from occurring when starting RStudio in the first place? I've tried deleting and redownloading RStudio but that doesn't seem to work. I'm currently using Mac OS Catalina.
Below is a screenshot of the error I receive when I open RStudio.
Thanks in advance.

I got similar issue with "setwd". When I did "save as" my existing code file from other folder to a new folder then I got an error: "cannot change working directory". When I did copy a code file from other folder and paste it into a new folder then I was able to run "setwd" and there was no error.

Related

Error while exporting zipped files from R linux server

I get the following R code execution error when I try to export and download zipped files from the R Linux server to my computer even though I have the zip and unzip files installed.
Error in system(createZipCommand, intern = TRUE) :
error in running command
Have anyone come across something similar and how did you solve it?
many Thanks
RJ
I think I figured out what's going on here. It appears that the PATH definition (echo $PATH) got corrupted. This was also preventing me from installing and updating packages.
I updated the path-definition in the '.Renviron' file as below
PATH=/usr/lib64/ccache:/usr/lib/rstudio-server/bin/postback:/usr/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/puppetlabs/bin
Saved this new '.Reviron' file in the home folder, logged off from R Studio, and signed back in. Everything seems to be fine now.

Getting error message in R Markdown KNITR

I am getting a very strange issue when using R-Markdown and when I press KNITR.
Each time I run the script I get the error below.
Error in read.csv(url("https://www.nomisweb.co.uk/api/v01/dataset/NM_1_1.data.csv?geography=1249902593...1249909543&date=latestMINUS2-latest&sex=7&item=1&measures=20100")) :
could not find function "read.csv"
This code does not feature in my script and exists in another document that I had created. I have changed the folder directory, cleared the environment. Yet this annoying error keeps appearing when pressing KNITR. I have created a new file, directory everything yet it keeps appearing.
I would be grateful for any pointers.
Try to run read.csv from utils package as shown
utils::read.csv(url("https://www.nomisweb.co.uk/api/v01/dataset/NM_1_1.data.csv?geography=1249902593...1249909543&date=latestMINUS2-latest&sex=7&item=1&measures=20100"))
or
library(utils)
read.csv(url("https://www.nomisweb.co.uk/api/v01/dataset/NM_1_1.data.csv?geography=1249902593...1249909543&date=latestMINUS2-latest&sex=7&item=1&measures=20100"))

RStudio initialization error, unexpected exception, fatal error

I am having an issue starting RStudio (desktop) that I did not have before.
When I fire-up RStudio, within seconds, the grey screen freezes with the following error message:
RStudio Initialization Error
Unable to establish connection with R session
Once I click 'OK', I get the following two error messages:
RStudio
Unexpected exception: The complexity of the regular expression exceeded predefined bounds...
and...
R encountered a fatal error. The session was terminated.
Any help in resolving these errors is much appreciated.
The "unexpected exception" error reads as though something's going wrong with RStudio trying to run something it's loading automatically as it is starting up. So, the related question is: how can I start RStudio fresh without opening any of the previous files/code/data?
I have tried uninstalling and reinstalling both R and RStudio, and R is installed fine (I can open and work on the R console).
I am working with:
Mac OSX 10.10.5
R 3.3.3
RStudio 1.1.423
Thank you!
Just received word from the RStudio team and their solution worked for me.
Indeed, RStudio is crashing while attempting to open a file you had
opened from a previous session. You should be able to work around this
by resetting your RStudio state.
The instructions to reset RStudio are here. Relevant excerpts:
RStudio Desktop stores your custom settings and options in a hidden
directory called RStudio-Desktop. If this directory does not exist,
RStudio will create it on start up. This directory includes user
settings, log files, and other state information. Removing (or
renaming) this directory will reset RStudio's state analogous to a
fresh installation.
We recommend renaming this directory to create a backup version
instead of completely deleting it. This allows you to save your
settings, in case you want to revert back to them. Additionally, if
you experienced a crash or RStudio failed to start, this directory may
contain vital information for determining the source of the error. In
this case, we recommend renaming this directory to
backup-rstudio-desktop and sending it along if asked by RStudio
Support.
So, simply removing the ~/.rstudio-desktop file (actually, renaming it to ~/backup-rstudio-desktop so that I have a backup) just solved the start-up issue!
As a FYI to anybody who tried the solution above without success, I ended up updating/reinstalling the xfun package (install.packages("xfun")), which resolved this issue for me when resetting my RStudio state did not.

Cant start spark in terminal

I took the following steps to get spark up and running in rstudio
Downloaded it at: http://spark.apache.org/
Stored the file in the following dir: "C:\Users\Marc\Apache"
Now I have a bin file containing a sparkR file called: spark-1.6.1-bin-hadoop2.6. However when I open up my terminal, move to the right dir and try to run it using:
.bin\sparkR
I get the following error:
R is not recognized as an internal or external command ....
Any thoughts on what goes wrong here?
¿Do you have R installed and added to the PATH?
Also check R CMD on Windows 7 Error - "R" is not recognized as an internal or external command, it may help you.

R on Ubuntu 14.04: Error in pdf("Plot.pdf") : cannot open file

I'm following textbook instructions to create a file using R and save a plot to it. When I try to make a pdf I get an error immediately:
pdf("Plot.pdf")
Error in pdf("Plot.pdf") : cannot open file 'Plot.pdf'
When I try to make a jpeg it gives no error, although I can't find the file on my computer, but when I try to write the plot to it I get the same kind of error.
jpeg("Plot.jpeg")
plot(x,y,col="green")
Error in plot.new() : could not open file 'Plot.jpeg'
Could it have something to do with using R on Ubuntu 14.04?
The problem was that I had entered R from etc/apt where I was altering sources.list to install R. I guess R could not make the files in that folder because it's a special system folder and is protected. Once I returned to my home folder and entered R again everything worked fine.

Resources