Changing directories in Spyder 3.5 - directory

I just updated my copy of Spyder on my Windows XP desktop to Spyder 3.5. How do I change directories so that the working directory is the one (in a subfolder in My documents)in which I have my Python Script and .txt data files (e.g. for running a regression)?

I had the same problem. I'm using the latest Spyder. I wanted my files to be in other than my home directory. I tried setting the current directory in Preferences. My files still wound up in my home directory. I tried the "cd" command. It said that the current directory was the one I wanted, but still the files were written to my home directory.
So I saved my script file in the directory I wanted. Now my files go where I would like.

Related

Delete directory before compilation

I am trying to delete a directory containing sub-directories and files before the compilation starts from a qmake pro file:
if exists($$OUT_PWD/android-build/src) del_tree($$OUT_PWD/android-build/src)
I tried different commands like QMAKE_DEL_TREE and $(DEL_TREE) but nothing worked. How can I delete an eventually existing directory?
It turned out that $(DEL_TREE) works fine. It did not work due to a mkspec bug in the Android Windows build invironment: https://bugreports.qt.io/browse/QTCREATORBUG-25373

Issue with serve_site() r blogdown

I'm using blogdown and Hugo to generate a website.
I've created a new R project and have downloaded the theme using:
blogdown::new_site(dir = "Theme", theme = 'pacollins/hugo-future-imperfect-slim') and I can preview the template once downloaded. However, if I close R and then restart and I use the add-in "serve site" I get the following error message:
Error in site_root(config) :
Could not find config.toml / config.yaml under...
and then the directory that the config.toml file is saved in (and all of the rest of the theme files) are listed.
I can't understand what's changing between being able to preview the site in R Studio Viewer, then quitting R and restarting and it not being able to find the config file.
I did find this advice: https://github.com/rstudio/blogdown/issues/48 which suggests that my working directory is not the root directory of the website. There are two things I don't understand:
1) How can the the root directory and working directory work together okay when I initially download the theme, until I quit R and restart, and then they appear to not be the same?
2) How to I change the root directory of the website to fix the issue?
Thanks!
If you followed the blogdown's documentation to create a new site with the command "blogdown::new_site(dir="/your/website/dir")", it will set your working directory to "/your/website/dir".
When you restart R/Rstudio, your current working directory is reset (probably to your home directory). You can check the current working directory with getwd().
The solution is simply set up the working directory:
The simpler way is to execute setwd("/your/website/dir"), then you should be able to run blogdown::serve_site()
The recommended way is to create a Rstudio project at /your/website/dir with File-New Project-Existing Directory. It will create a .Rproj file under the root directory of your website. After that, you can "open project" and work on your website, then preview with serve_site().

Can I change where RStudio saves snippets?

I would like to change where RStudio saves the r.snippets file that stores my code snippets. According to this site, RStudio should save to ~/.R/snippets/r.snippets. I use R_USER=C:/Users/JT/R in my Renviron.site file to set the location of ~. I think this code works, because when I check the location of ~ in RStudio I get:
> path.expand("~")
[1] "C:/Users/JT/R"
However, when I edit the snippets in RStudio it creates the r.snippets file in the folder C:\Users\JT\Documents\.R\snippets\. I want the r.snippets file to be saved in the folder C:\Users\JT\R\.R\snippets\.
Any ideas what I'm doing wrong? Thanks.
Over on the RStudio Community site this same question was asked as Can you change the directory the Rstudio looks for the r.snippets file?
Very helpful answer by RStudio employee kevinushey was:
While that directory isn't currently configurable, you might have luck
creating a symbolic link (or, on Windows, a junction point) to
re-route the snippets directory to another location.
tom_greenwood, the user who asked the question followed up with details of the steps he used:
1. Put you existing r.snippets file in the new directory on the shared drive. I called mine 'snippet files'
2. Delete the snippets directory which is inside the .R directory
3. Run cdm as an administrator.
4. Enter the command mklink /D "C:\Users\name.surname\Documents\.R\snippets" "T:\shared directory\snippet files"
5. Restart Rstudio.

R set working directory to current folder

I am currently working on a joint project, with all the files stored in a Dropbox. To avoid changing the working directory every time we change something, we use the following code:
this.dir = dirname(parent.frame(2)$ofile)
setwd(this.dir)
This is working fine when sourcing the code in Rstudio, but we are looking for a solution that is working outside RStudio.
The team is working on Mac and Windows.
For Windows, locate the file "Rprofile.site". In there, there will be set the following command setwd("PATH_TO_WD")
The same goes for Mac, the file is usually located at /etc/R/ path.
Just change the setwd in that file and everytime you launch R, the working directory will be set to the directory you want.
EDIT: In my Windows computer, the file is located at "C:\Program Files\R\R-3.2.3\etc

Why a folder name is different in Windows Explorer than command line or cygwin?

I have been using Robocopy to backup my computer files. I have been using the following command:
robocopy C:\Users\ J:\backup\ *.* /a /XD AppData /XJD /R:0 /s
When I look into my J drive in Windows Explorer I see folder named J:\Users\ but when I use dir from the command line I see a folder named j:\backup. The backup and user folder seem to be the same. I also tried looking at the content of the J drive in cygwin and see the backup folder but do not see a Users folder. What is going on? Is robocopy the culprit?
Just go into the backed up folder and delete the desktop.ini file. The folder name will revert back to the directory name. You copied the desktop.ini file from the source "users" folder that is causing the issue. You can and desktop.ini to your exclusions list with out any issues to your back up. They get created on the fly anyway if they are not present.
I tested this on a windows 7 pro machine just to verify.
The problem is not related to robocopy. The link below describes the problem.
https://superuser.com/questions/381110/windows-explorer-sees-different-file-name-from-cmd/381159#381159

Resources