[R] Several simple but hard tasks to do with R

Bert Gunter gunter.berton at gene.com
Thu Aug 20 01:24:57 CEST 2009


Rakknar:

I believe your subject line characterization reflects your ignorance of R,
rather than its inherent limitations.

1. logs. help.search("history") and ?savehistory shows you that R does
exactly what you want very easily (depending on the platform, which contrary
to the posting guide's request, you did not tell us). 

2. saving data.  ?save would show you how this can be trivially done
manually. ?addTaskCallback , an admittedly more sophisticated and less
well-known approach, would show you how this can be done simply and
automatically.

3. Conditional execution. R is a programming language! It is straightforward
to write a little program that does exactly what you want using R's built in
file system functionality. ?files will tell you what's available; I believe
file.exists() is what you want in a construct like

if(file.exists(yourfile.rdata))lm(...,data = read(yourfile.rdata))

So unless I have misconstrued your queries, I think with a little more
digging into the R docs (or supporting books, most of which are listed on
CRAN), you would find that contrary to your accusation, all these tasks are
indeed quite simple in R -- and that R's developers anticipated them years
ago.

Hope this clarifies...

Bert Gunter
Genentech Nonclinical Biostatisics

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Rakknar
Sent: Wednesday, August 19, 2009 2:52 PM
To: r-help at r-project.org
Subject: [R] Several simple but hard tasks to do with R


    Hello everybody. I've been learning R for about a month to do a
econometric study and now i'm stuck with some problems to make R do the
things I want. Here I give the list of things I wanna do from the most
simple to the more complex (for me of course):

1. Make a log. I've been using Stata and there i have a great tool to
register what the program do: the log file, wich it's a simple .txt file
where Stata writes every output it makes (not graphics of course). When I
wanted to make the same thing with R I started to use the function sink()
but it only register the results of the commands (summaries for example) and
not the commands itself, witch it's really uncomfortable because it's harder
to find out to witch command that results come from.

2. Saving objects in a .Rdata step by step. I want to save several
regressions of interest in one .Rdata file. I want to save this results one
by one. For example: make regression 1, save the result in the .Rdata file;
then make the regression 2 and save the results in the same .Rdata file. I
know I could make all the regressions and save the results all at once but
for the kind of study I want to make It would be much useful this way. I've
been using function save() but I only could save one result or all.

3. Conditional reading. I want to run regressions conditional to the
existence of a .Rdata file (the one I would be making in step two). The
condition would be something like
If "you find X.Rdata file" run regression with X.Rdata data else run
regression from the 0.

I hope I can find help here.

Thanks!!
-- 
View this message in context:
http://www.nabble.com/Several-simple-but-hard-tasks-to-do-with-R-tp25052563p
25052563.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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