[R] Can I save my console contents automatically?
Nobuaki Michihata
gha10771 at gmail.com
Fri Sep 17 15:02:49 CEST 2010
Hello Greg,
Thank you for your comment.
I had a chance to use Windows GUI R and I found several interesting
differences between Mac and Windows GUI R.
1. txtStart() command
- Windows GUI R - worked perfectly
- Mac GUI R version.string R version 2.11.1 (2010-05-31) (both
32bit and 64bit) - only make a null file
- Mac R version.string R version 2.11.1 (2010-05-31) on terminal
window - worked perfectly
(I also checked the permissions, but they were OK.)
2. Console
- Mac GUI R can display very long results and can save them from
the file menu (manually).
- Windows GUI R can only short results and can save only the
displayed results from the file menu.
3. sink()
- Mac GUI R - split = TRUE worked.
- Windows GUI R -split = TRUE didn't work (log on the file, but
didn't display the results on the console).
Thanks.
Nobu
> Currently comments (#) are ignored by txtStart and friends due to the task callback mechanism used. The txtComment function is available as a work around to insert comments into the output/commands.
>
> I tried running date() as below and everything worked as expected (the comments were missing, but the date command and result were in the file. I am running on windows where it looks like you are running on unix or linux. Can you send your OS and version of R and TeachingDemos? Also what are the permissions on the logtest.txt file that is created? (I've seen problems where the permissions for a directory allowed the creating of a file, but the default permissions on the file then do not allow modification).
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.snow at imail.org
> 801.408.8111
>
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
>> project.org] On Behalf Of Nobuaki Michihata
>> Sent: Thursday, September 16, 2010 8:24 AM
>> To: r-help
>> Subject: Re: [R] Can I save my console contents automatically?
>>
>> Hello David and Greg,
>> Thank you for your suggestions. These really help me.
>>
>> I'm curious about txtStart function of TeachingDemos library. It looks
>> exactly what I need.
>> So I installed TeachingDemos library and tried following.
>> -----
>> library(TeachingDemos)
>> setwd("/Users/NOBU/Documents/R_data/")
>> txtStart("logtest.txt", commands = TRUE, results = TRUE, append =
>> FALSE)
>>
>> #Top of commands
>> date()
>> #End of commands
>>
>> txtStop()
>> ---
>> Then I got following outputs on my console window, but I only got a
>> null file named "logtest.txt".
>> I tried several times by trial and error, but I couldn't find the
>> solution to log outputs on the logtest.txt.
>> ---
>> > library(TeachingDemos)
>> > setwd("/Users/NOBU/Documents/R_data/")
>> > txtStart("logtest.txt", commands = TRUE, results = TRUE, append =
>> FALSE)
>> Output being copied to text file,
>> use txtStop to end
>> txt>
>> txt> #Top of commands
>> txt> date()
>> [1] "Thu Sep 16 07:16:29 2010"
>> txt> #End of commands
>> txt>
>> txt> txtStop()
>>
>> Thank you for your help!
>> Nobu
>>
>>
>>
>> 2010/9/14 Nobuaki Michihata <gha10771 at gmail.com>:
>> > Dear All,
>> > I found a following solution from "http://r.789695.n4.nabble.com/".
>> > However this command can save only the result.
>> > Is there any good solution to save both commands themselves and the
>> results.
>> > Thank you for your help.
>> >
>> > sink("Filename_here.log", type=c("output","message"), split=TRUE)
>> >
>> > # Put commands here
>> > # However this method save only the results.
>> >
>> > sink()
>> >
>> > Nobu
>> >
>> >> Message: 33
>> >> Date: Fri, 10 Sep 2010 07:07:37 -0700
>> >> From: Nobuaki Michihata <gha10771 at gmail.com>
>> >> To: r-help at r-project.org, r-help at r-project.org
>> >> Subject: [R] Can I save my console contents automatically?
>> >> Message-ID:
>> >> <AANLkTimEZ-igqK6GzeYqERZaTg7m+chjbGJmAGmEL-
>> yJ at mail.gmail.com>
>> >> Content-Type: text/plain; charset=ISO-8859-1
>> >>
>> >> Dear All,
>> >>
>> >> I'm using R for Mac OS X Cocoa GUI R version 2.11.1.
>> >> I can save contents of my console window by using "command + s", but
>> I
>> >> would like to do same thing using R commands.
>> >> My question is can I save the contents automatically by using R
>> editor
>> >> with some R commands.
>> >>
>> >> Thank you.
>> >> Nobu
>> >
>>
>> ______________________________________________
>> 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