[R] Is 'history' recorded in Rscript?

Peng Yu pengyu.ut at gmail.com
Sat Sep 5 17:26:42 CEST 2009


Hi,

I run Rscript from the command line (bash). My OS is the following

$ cat  /etc/redhat-release
CentOS release 5 (Final)
$ uname -a
Linux selenium.cluster 2.6.18-53.1.13.el5 #1 SMP Tue Feb 12 13:02:30
EST 2008 x86_64 GNU/Linux
$ dmesg | grep gcc
Linux version 2.6.18-53.1.13.el5 (mockbuild at builder6.centos.org) (gcc
version 4.1.2 20070626 (Red Hat 4.1.2-14)) #1 SMP Tue Feb 12 13:02:30
EST 2008

I can use savehistory in an R session (that is after the R prompt
'>'). My file 'savehistory.R' only have the following three lines.

f=tempfile()
f
savehistory(f)


I run the command 'Rscript savehistory.R' from the bash command line,
which gave me the error I showed in my previous email. Can somebody
try if he/she receives the save error?

Regards,
Peng

On Sat, Sep 5, 2009 at 10:16 AM, David Winsemius<dwinsemius at comcast.net> wrote:
> You did not make it clear (to me anyway) what computing environment the
> Rscript command was issued from. I assumed probably incorrectly that you
> were doing this from inside an R session and did not understand that Rscript
> was an external program. If I was wrong about that, then you are going to
> need to provide more details about your operating system and how you have
> set up your R installation.
>
> I also do not know what you mean by a "save session". Did you at some time
> in the past execute a savehistory(file="savehistory,R") command at the end
> of a session and it's now in the directory that Rscript look for? That would
> be the only way that a savehistory.R file would exist.
>
> So what OS? What did you do before this failed effort? And what are you
> really trying to do?
>
> Then perhaps someone familiar with your OS can answer.
>
> --
> David
>
> .
> On Sep 5, 2009, at 10:52 AM, Peng Yu wrote:
>
>> Hi,
>>
>> I got the following error. Does it mean that the files in the save
>> session will not be saved in history in Rscript?
>>
>> $ Rscript savehistory.R
>>>
>>> f=tempfile()
>>> f
>>
>> [1] "/tmp/RtmpMEGKVq/file327b23c6"
>>>
>>> savehistory(f)
>>
>> Error in savehistory(file) : no history available to save
>> Execution halted
>>
>> Regards,
>> Peng
>>
>> On Sat, Sep 5, 2009 at 1:04 AM, David Winsemius<dwinsemius at comcast.net>
>> wrote:
>>>
>>> You should be looking for .Rhistory
>>>
>>> Some OSes make that task difficult. "savehistory" is not the file name
>>> but
>>> rather the name of the function that performs that operation. Try
>>> savehistory(file="text.Rhistory") and see if the history file is easier
>>> to
>>> find. Should be in your working directory.
>>>
>>> Rscript is a program, not a record of the prior session.
>>>
>>>
>>> --
>>>  David.
>>>
>>> On Sep 4, 2009, at 11:03 PM, Peng Yu wrote:
>>>
>>>> Hi,
>>>>
>>>> I run the following command and try to save the commands that have
>>>> been run in the script. But it seems that no history is recorded. Is
>>>> it because that the history is not recorded in Rscript?
>>>>
>>>> Regards,
>>>> Peng
>>>>
>>>> $ Rscript savehistory.R
>>>>>
>>>>> f=tempfile()
>>>>> f
>>>>
>>>> [1] "/tmp/Rtmp7WBjGG/file327b23c6"
>>>>>
>>>>> history()
>>>>
>>>> Error in savehistory(file) : no history available to save
>>>> Calls: history -> savehistory
>>>> Execution halted
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>




More information about the R-help mailing list