[R] save at relative directory

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Nov 8 16:21:47 CET 2011



On 08.11.2011 16:09, Alaios wrote:
> Hmm I will try something like that
>
>      if (file.exists('threshold')==FALSE)
>        dir.create(paste('./',abs(threshold)))
>
>      save(var,file=paste('./',abs(threshold),'/',DataSource[[4]],sep="")
>
> I just need a bit of confirmation If I am doing soemthing terribly wrong that might harm my filesystem.
>
> I also did accidentaly
> var<- -13
> dir.create(paste('./',var))
>
> which created a folder called -13 which I do not know how to remove it
>
>   rmdir -13
> rmdir: invalid option -- '1'
> Try `rmdir --help' for more information.


In R:
   unlink("-13", recursive=TRUE)

or in your shell:

I guess your intated OS can do:


rm --help
which points you to:
rm -r -- -13

Uwe Ligges



>
> B.R
> Alex
>
>
>
>
>
> ________________________________
> From: Joshua Wiley<jwiley.psych at gmail.com>
>
> Cc: "R-help at r-project.org"<R-help at r-project.org>
> Sent: Tuesday, November 8, 2011 2:43 PM
> Subject: Re: [R] save at relative directory
>
> Hi Alex,
>
> Look at some of these functions:
>
> apropos("dir")
> apropos("exists")
>
> Cheers,
>
> Josh
>
>
>
>> Dear all,
>> I have a variable called thres and before I run a script I set it to a value
>> like
>> thres<- -10
>> at the end of the execution I am issuing a save(variablename,file='Results')
>> which will end up with a file saved at the current directory with the name Results
>>
>> I would like though to use thres value and do the followingg
>> save at the directory called 10 so to get ./10/Results, (yes I want this in a relative order)
>>
>> My question is how I can also check if the directory exists R to create it?
>>
>> I would like to thank you in advance for your help
>>
>> B.R
>> Alex
>>         [[alternative HTML version deleted]]
>>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list