Creating project in existing directory erase all content of that directory

Hi everyone. Recently created a new project in Rstudio using an existing directory (actually my most important directory). I just realized that all the content of the directory was replaced. Basically I lost more than 2 years of work. Unfortunately, I was not aware of that possibility, I was under the impresion that I will just add a working directory in my existing folder.
Is there any chance to undo that? or at least a chance to recover all my files?
I will really appreciate advice or help
Sincerely
ALe

Hi, and welcome!

This isn't the expected behavior. Here's what happened when I created a new directory, populated it and then created a project using RStudio and the same files survived.

 $ 494:  mkdir lamb
 $ 495:  cd lamb
 $ 496:  touch mary had a little lamb whose fleece was white as snow
 $ 497:  l
total 0
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 a
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 as
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 fleece
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 had
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 lamb
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 little
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 mary
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 snow
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 was
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 white
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 whose
 $ 498:  l
total 8
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 a
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 as
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 fleece
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 had
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 lamb
-rw-r--r--  1 rc  staff   258B Mar  2 19:32 lamb.Rproj
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 little
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 mary
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 snow
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 was
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 white
-rw-r--r--  1 rc  staff     0B Mar  2 19:30 whose

If I lost a directory, I'd check to make sure it was where I thought it was. I'd check my shell history and the gui trash can.

If that didn't work, I'd immediately github all my other important work.

I wish you good luck.

It could be that the new project was created with the same directory name as your existing directory, but was created with a different path, in which case R might be pointing to the new empty directory rather that your existing directory. What operating system do you use?

1 Like

Hi, I am using High Sierra
I believe that was the problem
ALe

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.